Exemplo n.º 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);
        }
Exemplo n.º 2
0
 protected virtual void OnCompleted(WorkerCompletedEventArgs e)
 {
     if (this.Completed != null)
     {
         this.Completed(this, e);
     }
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 protected virtual void OnCompleted(WorkerCompletedEventArgs e)
 {
     if (this.Completed != null)
         this.Completed(this, e);
 }
Exemplo n.º 5
0
        private void SendOrPostWorkerCompleted(object state)
        {
            WorkerCompletedEventArgs e = state as WorkerCompletedEventArgs;

            this.OnCompleted(e);
        }