In most programming environments this requires many lines of code, especially if care is taken to avoid the overhead that may be caused by creating many threads.
In the simplest case, eventually there is no more such work, and the client calls EndAccomplish (passing the previously received object), which blocks until the method has completed and the result is available.
[11][12] In the .NET Framework documentation, the term event-based asynchronous pattern refers to an alternative API style (available since .NET 2.0) using a method named AccomplishAsync instead of BeginAccomplish.
Much more importantly, the API uses a special mechanism to run the callback method (which resides in an event object of type AccomplishCompleted) in the same thread in which BeginAccomplish was called.
This eliminates the danger of race conditions, making the API easier to use and suitable for software components; on the other hand this implementation of the pattern comes with additional object creation and synchronization overhead.