System 2.0.0.0 4.0.0.0 System.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 class provides ways to track and report the progress of an asynchronous task.

The following list identifies ways to use an object:

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

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

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

Tracks the lifetime of an asynchronous operation.

- Method
  2.0.0.0
  4.0.0.0
  System.Void To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Void

  Call the method to end the lifetime of an asynchronous operation. After this method is called for a particular task, calls to its corresponding will raise an exception.

  Ends the lifetime of an asynchronous operation.

- Method
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  The method invokes the delegate specified by the parameter without ending the lifetime of the asynchronous operation.

  You can call the method as often as you like while the lifetime of the asynchronous operation has not been ended by a call to . You can use the method to report progress or interim results back to clients.

  The parameter wraps the delegate you want called when you want to post an update about the status of the asynchronous task. The object will ensure that your delegate is invoked on the thread or context appropriate for the application model. Your method can optionally raise an event that notifies clients of a status change, progress update, or newly available incremental results.

  The parameter should be used to pass state to the delegate wrapped by the parameter. It might be a reference to an , or it might be a object. It may be desirable to derive your own class from to provide additional state storage.

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

  A object that wraps the delegate to be called when the operation ends. An argument for the delegate contained in the parameter.
- Method
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  Call the method to end the lifetime of an asynchronous operation. After this method is called for a particular task, calls to its corresponding object will raise an exception.

  The parameter wraps the delegate you want your class to call when the task's lifetime ends due to completion, cancellation, or failure of the task. The object will ensure that your delegate is invoked on the thread or context appropriate for the application model. Your delegate can optionally raise an event that notifies clients that the asynchronous task's lifetime has ended.

  The parameter is used to pass state information to the completion delegate . You can use an object, or an object as the parameter value. Alternatively, if you want to provide additional state storage, you can use an instance of a class you derive from the class.

  Ends the lifetime of an asynchronous operation.

  A object that wraps the delegate to be called when the operation ends. An argument for the delegate contained in the parameter.
- Property
  2.0.0.0
  4.0.0.0
  System.Threading.SynchronizationContext To be added. To be added.

  Gets the object that was passed to the constructor.

- Property
  2.0.0.0
  4.0.0.0
  System.Object To be added.

  If your class supports multiple asynchronous methods or multiple invocations of a single asynchronous method, clients will need a way to determine which asynchronous task is raising events. Your MethodNameAsync method should take a parameter of type that will act as a task ID. You will use this task ID when you call the , method and this will associate the client's task ID with a particular invocation of your asynchronous operation. This task ID is made available to your implementation through the property.

  Client code must be careful to provide a unique value for the property. Non-unique task IDs may cause your implementation to report progress and other events incorrectly. Your code should check for a non-unique task ID and raise an if one is detected.

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