There are two common use cases I’ve found:
- When you’re implementing an interface that allows asynchronous callers, but your implementation is synchronous.
- When you’re stubbing/mocking asynchronous code for testing.
More Related Contents:
- Waiting for async/await inside a task
- How can I prevent synchronous continuations on a Task?
- Awaiting multiple Tasks with different results
- Running multiple async tasks and waiting for them all to complete
- Using async/await for multiple tasks
- TAP global exception handler
- How to safely call an async method in C# without await
- Why should I prefer single ‘await Task.WhenAll’ over multiple awaits?
- Regarding usage of Task.Start() , Task.Run() and Task.Factory.StartNew()
- Task sequencing and re-entracy
- Synchronously waiting for an async operation, and why does Wait() freeze the program here
- Enforce an async method to be called once
- Is there anything like asynchronous BlockingCollection?
- Cancelling a pending task synchronously on the UI thread
- ConfigureAwait pushes the continuation to a pool thread
- multiple awaits vs Task.WaitAll – equivalent?
- Why use async and return await, when you can return Task directly?
- Executing tasks in parallel
- Difference between returning and awaiting a Task in an async method [duplicate]
- Should I worry about “This async method lacks ‘await’ operators and will run synchronously” warning
- Use Task.Run() in synchronous method to avoid deadlock waiting on async method?
- Task.Factory.StartNew with async lambda and Task.WaitAll
- A pattern for self-cancelling and restarting task
- What is the correct way to cancel an async operation that doesn’t accept a CancellationToken?
- The lack of non-capturing Task.Yield forces me to use Task.Run, why follow that?
- How do I get a return value from Task.WaitAll() in a console app?
- Task chaining (wait for the previous task to completed)
- Create a completed Task
- How can I run both of these methods ‘at the same time’ in .NET 4.5?
- Wrapping ManualResetEvent as awaitable task