• Top Posts

    What is an async method in C#


    • An async method is a method that returns to the calling method before completing all its work, and then completes its work while the calling method continues its execution.
       An async method must have the async keyword in its method header, and it must be before      the return type.
    – This modifier doesn’t do anything more than signal that the method contains one or more await expressions.
    – It contains one or more await expressions. These expressions represent tasks that can be done asynchronously.
    – It must have one of the following three return types.
    − void :If the calling method just wants the async method to execute, but doesn’t need any further interaction with it
    − Task : If the calling method doesn’t need a return value from the async method, but needs to be able to check on the async method’s state
    − Task :If the calling method is to receive a value of type T back from the call, the return type of the async method must be Task
    – An async method can have any number of formal parameters of any types but it cannot be out or ref parameters.
    – The name of an async method should end with the suffix Async.
    – Otherthan Methods, lambda expressions and anonymous methods can also act as async objects.

    No comments

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728