Share via

Guidelines for Asynchronous Programming

Asynchronous programming is a feature supported by many areas of the common language runtime, such as Remoting, ASP.NET, and Windows Forms. Asynchronous programming is a core concept in the .NET Framework. This topic introduces the design pattern for asynchronous programming.

The philosophy behind these guidelines is as follows:

  • The client should decide whether a particular call should be asynchronous.
  • It is not necessary for a server to do additional programming in order to support its clients' asynchronous behavior. The runtime should be able to manage the difference between the client and server views. As a result, the situation where the server has to implement IDispatch and do a large amount of work to support dynamic invocation by clients is avoided.
  • The server can choose to explicitly support asynchronous behavior either because it can implement asynchronous behavior more efficiently than a general architecture, or because it wants to support only asynchronous behavior by its clients. It is recommended that such servers follow the design pattern outlined in this document for exposing asynchronous operations.
  • Type safety must be enforced.
  • The runtime provides the necessary services to support the asynchronous programming model. These services include the following:
    • Synchronization primitives, such as critical sections and ReaderWriterLock instances.
    • Synchronization constructs such as containers that support the WaitForMultipleObjects method.
    • Thread pools.
    • Exposure to the underlying infrastructure, such as Message and ThreadPool objects.

See Also

Design Guidelines for Class Library Developers | Asynchronous Programming Design Pattern