Task.Run with Parameter(s)?

private void RunAsync() { //Beware of closures. String is immutable. string param = “Hi”; Task.Run(() => MethodWithParameter(param)); } private void MethodWithParameter(string param) { //Do stuff } Edit Due to popular demand I must note that the Task launched will run in parallel with the calling thread. Assuming the default TaskScheduler this will use the .NET … Read more

Is it possible to get successful results from a Task.WhenAll when one of the tasks fails? [duplicate]

Maybe public async Task<Task[]> RejectFailedFrom(params Task[] tasks) { try { await Task.WhenAll(tasks); } catch(Exception exception) { // Handle failed tasks maybe } return tasks.Where(task => task.Status == TaskStatus.RanToCompletion).ToArray(); } Usage var tasks = new[] { Task.FromResult(1), Task.FromException<int>(new ArgumentException(“fail1”)), Task.FromException<int>(new ArgumentException(“fail2”)) }; var succeed = await RejectFailedFrom(tasks); // [ tasks[0] ]

AfterPublish target not working

Note: The following applies to VS2010 and publishing web-application projects with the “Web Deploy” publish method selected in the ‘Build/Publish {projectname}’ dialog. Julien Hoarau’s correct in that “Publish” is NOT the name of the msbuild target invoked in the above case; the actual target name is “MSDeployPublish”. Therefore, you have to define a “Target” element … Read more

How do task killers work?

In a nutshell, Automatic Task Killers work by polling the OS for a list of currently running processes and the memory they are consuming. Then either with an intelligent algorithm or with user input the Task Killers issue a call to the system telling the system to kill the process. There are two apis you … Read more

How to return to the latest launched activity when re-launching application after pressing HOME? [duplicate]

Oh, I think I’ve found the answer. Because I was launching the app by using IntelliJ, it seems it launches the application in a different way than a user, clicking a home screen widget, would launch. It’s explained in the answer to another SO question: This is due to the intents being used to start … Read more