From C# 5.0, you can specify the method as
public async Task<bool> doAsyncOperation()
{
// do work
return true;
}
bool result = await doAsyncOperation();
More Related Contents:
- How and when to use ‘async’ and ‘await’
- async/await – when to return a Task vs void?
- When correctly use Task.Run and when just async-await
- If async-await doesn’t create any additional threads, then how does it make applications responsive?
- How can I limit Parallel.ForEach?
- Write a well designed async / non-async API
- Enforce an async method to be called once
- How to write Asynchronous LINQ query?
- Async await in linq select
- Good introduction to the .NET Reactive Framework [closed]
- Do the new C# 5.0 ‘async’ and ‘await’ keywords use multiple cores?
- Why would try/finally rather than a “using” statement help avoid a race condition?
- Calling async method on button click
- C# Begin/EndReceive – how do I read large data?
- ToArrayAsync() throws “The source IQueryable doesn’t implement IAsyncEnumerable”
- Factory for IAsyncEnumerable or IAsyncEnumerator
- Why was “SwitchTo” removed from Async CTP / Release?
- Suppress warning CS1998: This async method lacks ‘await’
- Should I worry about “This async method lacks ‘await’ operators and will run synchronously” warning
- C# Threading/Async: Running a task in the background while UI is interactable
- Async WebApi Thread.CurrentCulture
- Getting the Response of a Asynchronous HttpWebRequest
- Synchronous implementation of interface that returns Task
- Await vs Task.Result in an Async Method [duplicate]
- Running an asynchronous operation triggered by an ASP.NET web page request
- How to call back async function from Rx Subscribe?
- Async and Await with For Loop [duplicate]
- When is the best place to use Task.Result instead of awaiting Task
- Calling an async method from a synchronous method
- caching the result from a [n async] factory method iff it doesn’t throw