Use the AsyncPattern property to build service operations that can be called asynchronously on the server, the client, or both. The AsyncPattern property informs the runtime that a Begin method has a matched End method that conforms to the .NET Framework asynchronous method design pattern. Building server asynchronous methods that implement a service operation increases server scalability and performance without affecting the clients of the service, and is recommended when a service operation must return something to the client after performing a lengthy operation that can be performed asynchronously.
Clients remain unaffected because the asynchronous method pair on the server is an implementation detail that does not affect the underlying Web Services Description Language (WSDL) description of the operation. Such methods appear to clients as a single operation with <input> and correlated <output> messages. WCF automatically routes inbound messages to the Begin<methodName> method and routes the results of the End<methodName> call to the outbound message. Client channels, therefore, can represent the method pair as either a single synchronous operation or as an asynchronous operation pair. In no case does the client representation affect the asynchronous implementation on the server in any way.
Client contracts can use the AsyncPattern property to indicate an asynchronous method pair that the client can use to invoke the operation asynchronously. Typically, client applications use the ServiceModel Metadata Utility Tool (Svcutil.exe) tool and the /async option to generate a Begin<methodName> and End<methodName> method pair that the client can use to invoke the operation asynchronously.
Note: |
|---|
If a service operation has both an asynchronous and a synchronous version, the default behavior on the service is to invoke the synchronous version. |