Exemple #1
0
        public void ScriptAndCheckIn()
        {
            DoScriptWork worker = new DoScriptWork(backgroundWorker1_DoWork);

            worker.BeginInvoke(new AsyncCallback(backgroundWorker1_RunWorkerCompleted), null);

            System.Windows.Forms.Application.DoEvents();
        }
Exemple #2
0
        // This event handler demonstrates how to interpret
        // the outcome of the asynchronous operation implemented
        // in the DoWork event handler.
        private void backgroundWorker1_RunWorkerCompleted(IAsyncResult res)
        {
            AsyncResult result = (AsyncResult)res;

            Console.Out.WriteLine("Thread " + Thread.CurrentThread.ManagedThreadId.ToString());

            DoScriptWork del = (DoScriptWork)result.AsyncDelegate;

            try {
                DoSetButtonText d = new DoSetButtonText(SetButtonText);

                del.EndInvoke(res);

                if (isCancelled)
                {
                    // The user canceled the operation.
                    Log("Operation was canceled");
                    // The operation completed normally.
                    this.Invoke(d, ScriptDBBtn, "Begin");
                }
                else
                {
                    // The operation completed normally.
                    // All done
                    Log("Completed");
                    this.Invoke(d, "Begin");

                    if (exitWhenFinished)
                    {
                        Environment.Exit(0);
                    }
                }
            } catch (Exception ex) {
                Log("Error in backgroundWorker1_RunWorkerCompleted. " + ex.Message);

                ScriptDBBtn.Text = "Begin";
            }
        }