private void WorkerThreadStart(AsyncOperation asyncOp, object userState, object argument) { Exception error = null; bool cancelled = false; DoWorkEventArgs e = new DoWorkEventArgs(userState, argument); try { this.OnDoWork(e); if (e.Cancel) { cancelled = true; } } catch (Exception ex) { error = ex; } lock (userStateToLifetime.SyncRoot) { userStateToLifetime.Remove(asyncOp.UserSuppliedState); } WorkerCompletedEventArgs arg = new WorkerCompletedEventArgs(error, cancelled, asyncOp.UserSuppliedState, argument); asyncOp.PostOperationCompleted(this.SendOrPostWorkerCompleted, arg); }
protected virtual void OnCompleted(WorkerCompletedEventArgs e) { if (this.Completed != null) { this.Completed(this, e); } }
private void WorkerThreadStart(AsyncOperation asyncOp, object userState, object argument) { Exception error = null; bool cancelled = false; DoWorkEventArgs e = new DoWorkEventArgs(userState, argument); try { this.OnDoWork(e); if (e.Cancel) cancelled = true; } catch (Exception ex) { error = ex; } lock (userStateToLifetime.SyncRoot) { userStateToLifetime.Remove(asyncOp.UserSuppliedState); } WorkerCompletedEventArgs arg = new WorkerCompletedEventArgs(error, cancelled, asyncOp.UserSuppliedState, argument); asyncOp.PostOperationCompleted(this.SendOrPostWorkerCompleted, arg); }
protected virtual void OnCompleted(WorkerCompletedEventArgs e) { if (this.Completed != null) this.Completed(this, e); }
private void SendOrPostWorkerCompleted(object state) { WorkerCompletedEventArgs e = state as WorkerCompletedEventArgs; this.OnCompleted(e); }