Пример #1
0
        //****************************************************
        //Purpose : This event gets raised when m_bkgdWorker(BackgroundWorker).DoWork is finished
        //Inputs  : Sender and RunWorkerCompletedEventArgs that holds a TestResultUpdate_t
        //Sets    : Raises event to update test status info
        //Returns :
        //****************************************************
        private void m_bkgdWorker_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)
        {
            if (!(e.Error == null))
            {
                //RaiseEvent ev_BackgroundUpdatePictureBox(Color.HotPink, m_scanindex)
                //RaiseEvent ev_BackgroundUpdatePictureBox2(3, m_scanindex)
                if (ev_ShipImageCallback != null)
                {
                    ev_ShipImageCallback(false, "Failed: " + e.Error.Message);
                }
            }
            else if (e.Cancelled)
            {
                // Next, handle the case where the user canceled the
                // operation.
                // Note that due to a race condition in
                // the DoWork event handler, the Cancelled
                // flag may not have been set, even though
                // CancelAsync was called.
                //HaltTest(m_TestList(m_ndxTest))
                //RaiseEvent ev_BackgroundUpdatePictureBox(Color.HotPink, m_scanindex)
                //RaiseEvent ev_BackgroundUpdatePictureBox2(1, m_scanindex)
                if (m_errMsg == "")
                {
                    if (ev_ShipImageCallback != null)
                    {
                        ev_ShipImageCallback(false, "Failed: Test Cancelled by operator");
                    }
                }
                else
                {
                    if (ev_ShipImageCallback != null)
                    {
                        ev_ShipImageCallback(false, m_errMsg);
                    }
                }
            }
            else
            {
                // Finally, handle the case where the operation succeeded.
                //Res = CType(e.Result, TESTRESULT_t)

                if (ev_ShipImageCallback != null)
                {
                    ev_ShipImageCallback(m_status, m_errMsg);
                }
            }
            System.Diagnostics.Debug.Print("thread complete");
            if (m_progress != null)
            {
                m_progress.Dispose();
                m_progress = null;
            }
        }
Пример #2
0
        public void StartThread(string cmdSnap, string cmdShip)
        {
            if (m_progress == null)
            {
                m_progress = new frm_Progress();
            }

            m_workerStruct.imgFn   = m_filename;
            m_workerStruct.imgSnap = cmdSnap;
            m_workerStruct.imgShip = cmdShip;
            while (m_bkgdWorker.IsBusy)
            {
                System.Windows.Forms.Application.DoEvents();
            }
            m_bkgdWorker.RunWorkerAsync(m_workerStruct);
            //m_bkgdWorker.RunWorkerAsync(fn);
        }