Esempio n. 1
0
        void multiBackgroundWorker1_RunWorkerCompleted(object sender, Core.MultiRunWorkerCompletedEventArgs e)
        {
            //3步
            //1.判断是否出现错误
            //2.判断是否被取消
            //3.已成功.
            FileData model  = null;
            string   taskId = e.TaskId.ToString();

            if (e.Error != null)
            {
                model = UpdateListView(taskId, "Error");
            }
            else if (e.Cancelled)
            {
                model = UpdateListView(taskId, "Cancelled");
            }
            else
            {
                model = UpdateListView(taskId, e.Result.ToString());
            }
            Debug.WriteLine(model == null);
            if (model != null)
            {
                model.Tag = null;
            }
        }
 public void OnRaiseRunWorkerCompleted(MultiRunWorkerCompletedEventArgs e)
 {
     if (RunWorkerCompleted != null)
     {
         RunWorkerCompleted(this, e);
     }
 }
Esempio n. 3
0
        void multiBackgroundWorker1_RunWorkerCompleted(object sender, Core.MultiRunWorkerCompletedEventArgs e)
        {
            //3步
            //1.判断是否出现错误
            //2.判断是否被取消
            //3.已成功.
            string       taskId = e.TaskId.ToString();
            ListViewItem lvi    = null;

            if (e.Error != null)
            {
                lvi = UpdateListView(taskId, "Error");
            }
            else if (e.Cancelled)
            {
                lvi = UpdateListView(taskId, "Cancelled");
            }
            else
            {
                lvi = UpdateListView(taskId, e.Result.ToString());
            }
            lvi.Tag = null;
        }
        public void WorkThreadStart(AsyncOperation async, object argument)
        {
            AsyncOperation asyncOp   = async;
            bool           cancelled = false;
            Exception      error     = null;
            object         result    = null;

            try
            {
                MultiDoWorkEventArgs args = new MultiDoWorkEventArgs(asyncOp.UserSuppliedState, argument);
                this.OnDoWork(args);
                if (args.Cancel)
                {
                    cancelled = true;
                }
                else
                {
                    result = args.Result;
                }
            }
            catch (Exception exception)
            {
                error = exception;
            }

            if (!cancelled)
            {
                lock (this.userStateToLifeTime.SyncRoot)
                {
                    this.userStateToLifeTime.Remove(asyncOp.UserSuppliedState);
                }
            }

            MultiRunWorkerCompletedEventArgs completeArgs = new MultiRunWorkerCompletedEventArgs(asyncOp.UserSuppliedState, result, error, cancelled);

            asyncOp.PostOperationCompleted(onRunWorkerCompletedDelegate, completeArgs);
        }
 public void RunWorker(MultiRunWorkerCompletedEventArgs e)
 {
     MultiRunWorkerCompletedEventArgs args = e as MultiRunWorkerCompletedEventArgs;
 }
        public void WorkerCompleted(object operationState)
        {
            MultiRunWorkerCompletedEventArgs args = operationState as MultiRunWorkerCompletedEventArgs;

            this.OnRaiseRunWorkerCompleted(args);
        }
 public void OnRaiseRunWorkerCompleted(MultiRunWorkerCompletedEventArgs e)
 {
     if (RunWorkerCompleted != null)
     {
         RunWorkerCompleted(this, e);
     }
 }
        public void WorkThreadStart(AsyncOperation async, object argument)
        {
            AsyncOperation asyncOp = async;
            bool cancelled = false;
            Exception error = null;
            object result = null;

            try
            {
                MultiDoWorkEventArgs args = new MultiDoWorkEventArgs(asyncOp.UserSuppliedState, argument);
                this.OnDoWork(args);
                if (args.Cancel)
                {
                    cancelled = true;
                }
                else
                {
                    result = args.Result;
                }

            }
            catch (Exception exception)
            {
                error = exception;
            }

            if (!cancelled)
            {
                lock (this.userStateToLifeTime.SyncRoot)
                {
                    this.userStateToLifeTime.Remove(asyncOp.UserSuppliedState);
                }
            }

            MultiRunWorkerCompletedEventArgs completeArgs = new MultiRunWorkerCompletedEventArgs(asyncOp.UserSuppliedState, result, error, cancelled);
            asyncOp.PostOperationCompleted(onRunWorkerCompletedDelegate, completeArgs);
        }
 public void RunWorker(MultiRunWorkerCompletedEventArgs e)
 {
     MultiRunWorkerCompletedEventArgs args = e as MultiRunWorkerCompletedEventArgs;
 }