async and await in c#

Use the async modifier to specify that a method, lambda expression, or anonymous method is asynchronous. If you use this modifier on a method or expression, it's referred to as an async method.
public async Task<int> ExampleMethodAsync()
{
    // . . . .
}

If you're new to asynchronous programming or do not understand how an async method uses the await keyword to do potentially long-running work without blocking the caller’s thread, you should read the introduction in Asynchronous Programming with Async and Await (C# and Visual Basic).


https://msdn.microsoft.com/en-us/library/mt674882.aspx




The await operator is applied to a task in an asynchronous method to suspend the execution of the method until the awaited task completes. The task represents ongoing work.
The asynchronous method in which await is used must be modified by the async keyword. Such a method, defined by using the async modifier, and usually containing one or more await expressions, is referred to as an async method.
System_CAPS_noteNote
The async and await keywords were introduced in Visual Studio 2012. For an introduction to async programming, see Asynchronous Programming with Async and Await (C# and Visual Basic).
The task to which the await operator is applied typically is the return value from a call to a method that implements the Task-Based Asynchronous Pattern. Examples include values of type Task or Task<TResult>.

Comments