- Introduced in
.Net 4.5 - The method signature includes an
asyncmodifier. - The name of an
asyncmethod, by convention, ends with anAsyncsuffix. - The return type is one of the following types:
Task<TResult>if your method has a return statement in which the operand has typeTResult.Taskif your method has no return statement or has a return statement with no operand.voidif you're writing anasyncevent handler. This return type is used primarily to define event handlers, where a void return type is required.
- The method usually includes at least one
awaitexpression, which marks a point where the method can't continue until the awaited asynchronous operation is complete. In the meantime, the method is suspended, and control returns to the method's caller. - When the
asyncmethod eventually completes its work, the task is marked as completed and the result, if any, is stored in the task. - The
asyncandawaitkeywords don't cause additional threads to be created. Async methods don't require multithreading because anasyncmethod doesn't run on its own thread. The method runs on the current synchronization context and uses time on the thread only when the method is active. - The marked
asyncmethod can useawaitto designate suspension points. Theawaitoperator tells the compiler that theasyncmethod can't continue past that point until the awaited asynchronous process is complete. In the meantime, control returns to the caller of theasyncmethod. - The suspension of an
asyncmethod at anawaitexpression doesn't constitute an exit from the method, and finally blocks don’t run. - An
asyncmethod typically contains one or more occurrences of anawaitoperator, but the absence ofawaitexpressions doesn’t cause a compiler error. If anasyncmethod doesn’t use anawaitoperator to mark a suspension point, the method executes as a synchronous method does, despite theasyncmodifier. The compiler issues a warning for such methods. - An
asyncmethod that has a void return type can’t be awaited, and the caller of a void-returning method can't catch any exceptions that the method throws. - An
asyncmethod can't declarereforoutparameters, but the method can call methods that have such parameters.
Source: https://msdn.microsoft.com/en-us/library/mt674882.aspx
Hello everyone, you'll be pleased to know that I stumbled on a page today that explains why lawyers are being barred from attorney suspended from practice I have received entire information about it. And now I'd like to share that information with all of you. I hope you enjoyed reading this information