This documentation is archived and is not being maintained.

AsyncOperationManager Class

Provides concurrency management for classes that support asynchronous method calls. This class cannot be inherited.

Namespace: System.ComponentModel
Assembly: System (in system.dll)

public ref class AsyncOperationManager abstract sealed
public final class AsyncOperationManager
public final class AsyncOperationManager
Not applicable.

If your class needs to provide asynchronous behavior according to the Asynchronous Pattern for Components, you will encounter a number of concurrency management issues. Among these is the requirement to ensure that event handlers are called on a thread or context that is appropriate for the application model (for example, Windows Forms applications, ASP.NET applications, console applications, and so on). The AsyncOperationManager provides a convenient way to create a class that runs properly under all application models supported by the .NET Framework.

The AsyncOperationManager class has one method, CreateOperation, which returns an System.ComponentModel.AsyncOperation that can be used to track the duration of a particular asynchronous task. The System.ComponentModel.AsyncOperation for a task can be used to alert clients when a task completes. It can also be used to post progress updates and incremental results without terminating the operation.

For more information about implementing asynchronous classes, see Implementing the Asynchronous Pattern for Components.

The following code example demonstrates using the AsyncOperationManager class to create a class that supports asynchronous operations for any application model. It shows how to implement a class that tests a number to determine whether it is prime. This calculation can be time consuming, so it is done on a separate thread. Progress reports, incremental results, and completion notifications are handled by the AsyncOperation class, which ensures that the client's event handlers are called on the proper thread or context.

For a full code listing, see How to: Implement a Component that Supports the Asynchronous Pattern. For a full code listing of a client form, see How to: Implement a Client of the Asynchronous Pattern for Components.

No code example is currently available or this language may not be supported.
// This method starts an asynchronous calculation. 
// First, it checks the supplied task ID for uniqueness.
// If taskId is unique, it creates a new WorkerEventHandler 
// and calls its BeginInvoke method to start the calculation.
public void CalculatePrimeAsync(int numberToTest, Object taskId)
    // Create an AsyncOperation for taskId.
    AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId);
    synchronized (userStateToLifetime.get_SyncRoot()) 
        // Multiple threads will access the task dictionary,
        // so it must be locked to serialize access.
        if (userStateToLifetime.Contains(taskId)) {
            throw new ArgumentException("Task ID parameter must be unique", 

        userStateToLifetime.set_Item(taskId, asyncOp);

    // Start the asynchronous operation.
    WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker);


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0