Пример #1
0
        // Worker thread function.
        // Called indirectly from btnStartThread_Click
        private void WorkerThreadFunction()
        {
            LongProcess longProcess;

            longProcess = new LongProcess(m_EventStopThread, m_EventThreadStopped, this);

            longProcess.Run();
        }
Пример #2
0
        // Start thread button is pressed
        private void btnStartThread_Click(object sender, System.EventArgs e)
        {
            listBox1.Items.Clear();
            btnStartThread.Enabled = false;
            btnStopThread.Enabled  = true;

            #region ³õʼ»¯´úÂë
            longProcess      = new LongProcess();
            ThreadStart dele = delegate()
            {
                longProcess.Run();
            };
            // create worker thread instance
            Thread m_WorkerThread = new Thread(dele);
            m_WorkerThread.Name          = "Worker Thread Sample"; // looks nice in Output window
            this.longProcess.Work_thread = m_WorkerThread;
            m_WorkerThread.Start();
            #endregion
        }