/// <summary> /// /// </summary> /// <param name="profile"></param> /// <param name="servers"></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 GetServersCompletionMethod(string profile, List <string> servers, 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 // ServersRetrievedEventArgs. GetServersCompletedEventArgs e = new GetServersCompletedEventArgs( profile, servers, x, cancelled, asyncOp.UserSuppliedState); // End the task. The asyncOp object is responsible // for marshaling the call. asyncOp.PostOperationCompleted(onGetServersCompletedDelegate, 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 OnGetServersCompleted(GetServersCompletedEventArgs e) { if (GetServersCompletedHandler != null) { GetServersCompletedHandler(this, e); } }
/// <summary> /// /// </summary> /// <param name="profile"></param> /// <param name="servers"></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 GetServersCompletionMethod(string profile, List<string> servers, 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 // ServersRetrievedEventArgs. GetServersCompletedEventArgs e = new GetServersCompletedEventArgs( profile, servers, x, cancelled, asyncOp.UserSuppliedState); // End the task. The asyncOp object is responsible // for marshaling the call. asyncOp.PostOperationCompleted(onGetServersCompletedDelegate, 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. }
// This method is invoked via the AsyncOperation object, // so it is guaranteed to be executed on the correct thread. protected void GetServersCompleted(object operationState) { GetServersCompletedEventArgs e = operationState as GetServersCompletedEventArgs; OnGetServersCompleted(e); }
protected void OnGetServersCompleted(GetServersCompletedEventArgs e) { if (GetServersCompletedHandler != null) { GetServersCompletedHandler(this, e); } }