Inheritance: System.ComponentModel.AsyncCompletedEventArgs
示例#1
0
        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);
        }
示例#2
0
 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);
 }
示例#5
0
        private void SendOrPostWorkerCompleted(object state)
        {
            WorkerCompletedEventArgs e = state as WorkerCompletedEventArgs;

            this.OnCompleted(e);
        }