/// <summary> /// /// </summary> /// <param name="command"></param> /// <param name="result"></param> /// <param name="x"></param> /// <param name="cancelled"></param> /// <param name="asyncOp"></param> /// <remarks> /// This is the method that the underlying, free-threaded /// asynchronous behavior will invoke. This will happen on /// an arbitrary thread. /// </remarks> protected void GetProfileCompletionMethod(string entity, string profile, Exception x, bool cancelled, AsyncOperation asyncOp) { // If the task was not previously cancelled, // remove the task from the lifetime collection. if (!cancelled) { lock (userStateToLifetime.SyncRoot) { userStateToLifetime.Remove(asyncOp.UserSuppliedState); } } // Package the results of the operation in a // ProfileRetrievedEventArgs. GetProfileCompletedEventArgs e = new GetProfileCompletedEventArgs( entity, profile, x, cancelled, asyncOp.UserSuppliedState); // End the task. The asyncOp object is responsible // for marshaling the call. asyncOp.PostOperationCompleted(onGetProfileCompletedDelegate, e); // Note that after the call to OperationCompleted, // asyncOp is no longer usable, and any attempt to use it // will cause an exception to be thrown. }
protected void OnGetProfileCompleted(GetProfileCompletedEventArgs e) { if (GetProfileCompletedHandler != null) { GetProfileCompletedHandler(this, e); } }
// This method is invoked via the AsyncOperation object, // so it is guaranteed to be executed on the correct thread. protected void GetProfileCompleted(object operationState) { GetProfileCompletedEventArgs e = operationState as GetProfileCompletedEventArgs; OnGetProfileCompleted(e); }