About 120,000 results
Open links in new tab
  1. c# - What is the difference between task and thread? - Stack …

    Nov 9, 2010 · In C# 4.0, we have Task in the System.Threading.Tasks namespace. What is the true difference between Thread and Task. I did some sample program (help taken from …

  2. Understanding async / await in C# - Stack Overflow

    I'm starting to learn about async / await in C# 5.0, and I don't understand it at all. I don't understand how it can be used for parallelism. I've tried the following very basic program: …

  3. c# - _ = Task.Run vs async void - Stack Overflow

    May 21, 2020 · Task.Yield essentially means "there's more to do, but I don't want to tie up the current thread; hand control back to the caller, and do the next bit of this work on the thread …

  4. c# - async/await - when to return a Task vs void? - Stack Overflow

    Normally, you would want to return a Task. The main exception should be when you need to have a void return type (for events). If there's no reason to disallow having the caller await your …

  5. When correctly use Task.Run and when just async-await

    I would like to ask you on your opinion about the correct architecture when to use Task.Run. I am experiencing laggy UI in our WPF .NET 4.5 application (with Caliburn Micro framework). …

  6. c# - What is the best way to catch exception in Task? - Stack …

    With System.Threading.Tasks.Task<TResult>, I have to manage the exceptions that could be thrown. I'm looking for the best way to do that. So far, I've created a base class that …

  7. Is Task.Result the same as .GetAwaiter.GetResult ()?

    351 Task.GetAwaiter().GetResult() is preferred over Task.Wait and Task.Result because it propagates exceptions rather than wrapping them in an AggregateException. However, all …

  8. c# - How do I get the result or return value of a Task? - Stack …

    Can someone explain to me how to return the result of a Task? I currently am trying to do the following but my Tasks are not returning my List that I expect? What is the problem here? …

  9. c# - When to use Task.Delay, when to use Thread.Sleep? - Stack …

    Sep 26, 2020 · Task.Delay is the preferred method for asynchronous programming in C#, because it allows you to wait asynchronously without blocking a thread. Thread.Sleep blocks …

  10. c# - HttpClient - A task was cancelled? - Stack Overflow

    Mar 21, 2015 · 30 I ran into this issue because my Main method wasn't waiting for the task to complete before returning, so the Task<HttpResponseMessage> was being cancelled when …