Ends the lifetime of an asynchronous operation.
Assembly: System (in System.dll)
Call the method to end the lifetime of an asynchronous operation. After this method is called for a particular task, calls to its corresponding AsyncOperation object will raise an exception.
The d parameter wraps the delegate you want your class to call when the task's lifetime ends because of completion, cancellation, or failure of the task. The AsyncOperation object will make sure 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 arg parameter is used to pass state information to the completion delegate d. You can use an AsyncOperation object, or an System.ComponentModel.AsyncCompletedEventArgs 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 System.ComponentModel.AsyncCompletedEventArgs class.Notes to Inheritors
Inheritors must make the invocation asynchronous, so that class library providers do not need to concern themselves with potential stack overflows if they assume asynchrony but a particular application model happens to be synchronous. The method should be interpreted as an "ending the lifetime" call, meaning the implementation needs to do what is appropriate for the application model. For instance, ASP.NET will decrement its count of outstanding asynchronous operations. This should also make sure that any subsequent calls into the operation will fail, since it has now completed.
For more information about how to implement asynchronous classes, see Implementing the Event-based Asynchronous Pattern in the .NET Framework documentation.
The following code example demonstrates how to use the method to end the lifetime of an asynchronous operation. This code example is part of a larger example provided for the System.ComponentModel.AsyncOperationManager class.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.