Ejemplo n.º 1
0
 public void RunWorkerAsync(object argument)
 {
     mCancelPending = false;
     if (DoWork != null)
     {
         DoWorkEventArgsBw args     = new DoWorkEventArgsBw(argument);
         AsyncCallback     callback = new AsyncCallback(ReportCompletion);
         DoWork.BeginInvoke(this, args, callback, args);
     }
 }
Ejemplo n.º 2
0
 public void RunWorkerAsync(object pArgument)
 {
     cancelPending = false;
     if (DoWork != null)
     {
         WorkerEventArgs _args     = new WorkerEventArgs(pArgument);
         AsyncCallback   _callback = new AsyncCallback(reportCompletion);
         //NOTE: ? why do we need ar here ?
         ar = DoWork.BeginInvoke(this, _args, _callback, _args);
     }
 }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("Window Form Method.ThreadId:#{0}", Thread.CurrentThread.ManagedThreadId);
            this.AddValue("Asynchronous Start.");

            var context = SynchronizationContext.Current;

            DoWork work = DoWorkMethod;

            work.BeginInvoke(OnWorkCallback, context);
        }
Ejemplo n.º 4
0
        internal void Run()
        {
            if (DoWork == null)
            {
                return;
            }

            _isCancelPending = false;

            DoWorkEventArgs args = new DoWorkEventArgs(_argument);

            DoWork.BeginInvoke(this, args, new AsyncCallback(ReportCompletion), args);
        }
Ejemplo n.º 5
0
        private static void AsyncTest()
        {
            DoWork       d = new DoWork(WorkPro);              //no.1
            IAsyncResult r = d.BeginInvoke(1000, CallBack, d); //no.2

            //int result = d.EndInvoke(r);
            //Console.WriteLine(result);
            for (var i = 0; i < 100; i++) //no.3
            {
                Thread.Sleep(10);         //主线程需要做的事情
            }
            Console.WriteLine("主线程done");
        }
Ejemplo n.º 6
0
        void OnStart(object sender, EventArgs e)
        {
            CancelPending       = false;
            m_ProgressBar.Value = 0;
            m_StatusLabel.Text  = "Status: In Progress";

            DoWork        doWork   = new DoWork(DoBackgroundProcessing);
            AsyncCallback callback = new AsyncCallback(OnCompleted);

            doWork.BeginInvoke(100, callback, null);

            m_CancelButton.Enabled = true;
            m_StartButton.Enabled  = false;
        }
Ejemplo n.º 7
0
 public IAsyncResult BeginDisplayInitializationUI(IClientChannel channel, AsyncCallback callback, object state)
 {
     Console.WriteLine("Begin");
     d = new DoWork(DisplayInitializationUI);
     return(d.BeginInvoke(null, null));
 }