How many models of Asynchronous development in .NET?

Thread.Start - brutal

delegate.BeginInvoke/EndInvoke - 'old' standard

ThreadPool.QueueUserWorkItem - smart

TaskFactory.StartNew - the only way to do it correct (according to Patterns of parallel programming book | i recommend you to read it first for disambiguation)


There's a lot that can be caught in the term "asynchronous development."


For one, you could want to execute code on a background thread. I recently updated a blog post of mine contrasting several common approaches to executing code in the background. Here's the list, in order from most desirable to least:

  1. Task (as used by async/await).
  2. Task (as used by the Task Parallel Library).
  3. BackgroundWorker.
  4. Delegate.BeginInvoke.
  5. ThreadPool.QueueUserWorkItem.
  6. Thread

On another hand, you could want to represent an asynchronous operation (which may or may not be actual code executing on a background thread). In that case, there are several approaches, in order from most desirable to least:

  1. Task (in the style of the Task-based Asynchronous Pattern (TAP))
  2. IAsyncResult with Begin*/End* methods (which has the unfortunate name Asynchronous Programming Model (APM)).
  3. A component written using the Event-based Asynchronous Pattern (EAP).

(As a side note, BackgroundWorker is EAP, and Delegate.BeginInvoke is APM).


On another hand, you could mean asynchronous programming in general, which can be interpreted to mean a reactive approach. In this case, there are only two approaches that I know of:

  1. Reactive Extensions (Rx).
  2. Event-based Asynchronous Pattern (EAP).

However, you could make a case that any event-driven program is reactive to some extent, so just handling UI events is a (simple) form of "asynchronous programming."


Also, these are only the common models. Any platform or library can add more. Here's some off the top of my head:

  • The Socket class has a special form of APM that can be used to minimize memory allocations. It works very similarly to APM but does not fit the pattern.
  • The WinRT runtime (coming in Windows 8) has its own representations of asynchronous operations (IAsyncOperation<TResult> and IAsyncInfo).
  • Windows Phone has specific support for a background agent, which permits you to run code in the background even if your app isn't currently running.