AsyncOperation Class


Tracks the lifetime of an asynchronous operation.

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


[HostProtectionAttribute(SecurityAction::LinkDemand, SharedState = true)]
public ref class AsyncOperation sealed 


Gets the SynchronizationContext object that was passed to the constructor.


Gets or sets an object used to uniquely identify an asynchronous operation.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Finalizes the asynchronous operation.(Overrides Object::Finalize().)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Ends the lifetime of an asynchronous operation.

System_CAPS_pubmethodPost(SendOrPostCallback^, Object^)

Invokes a delegate on the thread or context appropriate for the application model.

System_CAPS_pubmethodPostOperationCompleted(SendOrPostCallback^, Object^)

Ends the lifetime of an asynchronous operation.


Returns a string that represents the current object.(Inherited from Object.)

When you implement a class according to the Event-based Asynchronous Pattern Overview, you may need to track the lifetime of each asynchronous operation invoked on an instance of your class. The AsyncOperation class provides ways to track and report the progress of an asynchronous task.

The following list identifies ways to use an AsyncOperation object:

  • To report progress and interim results to the client, call Post from your asynchronous worker code.

  • To indicate that an asynchronous task has completed, or to cancel a pending asynchronous task, call PostOperationCompleted.

Your class should get an AsyncOperation object for each asynchronous task by calling AsyncOperationManager::CreateOperation when each task starts. To allow the client to distinguish separate asynchronous tasks, AsyncOperationManager::CreateOperation takes a parameter for a unique client-provided token, which becomes the UserSuppliedState property. It can then be used by client code to identify the particular asynchronous task that is raising progress or completion events.

Notes to Inheritors:

Implementers must ensure the PostOperationCompleted and Post invocations are asynchronous, so that class library providers do not need to concern themselves with potential stack overflows if they assume asynchronous behavior in a particular application model that happens to be synchronous.

For more information about implementing asynchronous classes, see Implementing the Event-based Asynchronous Pattern.

The following code example demonstrates using an AsyncOperation object to track the lifetime of asynchronous operations. This code example is part of a larger example provided for the System.ComponentModel::AsyncOperationManager class.

For a full code listing, see How to: Implement a Component That Supports the Event-based Asynchronous Pattern. For a full code listing of a client form, see How to: Implement a Client of the Event-based Asynchronous Pattern.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 10
.NET Framework
Available since 2.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0

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

Return to top