BackgroundWorker

Constants.Worker = new BackgroundWorker();
Constants.Worker.WorkerSupportsCancellation = true;
Constants.Worker.DoWork += delegate
    {
        while (!Constants.Worker.CancellationPending)
        {
            Thread.Sleep(1000);
            for (int i = 0; i < ProgramStatus.ChannelCount; i++)
            {
                if (ProgramStatus.IsStopped[i])
                {
                    pictureBoxs[i].Image = pictureBoxs[i].ErrorImage;
                }
            }
        }
    };
Constants.Worker.RunWorkerAsync();
Closing += delegate
    {
        Constants.Worker.CancelAsync();
    };

 

posted on 2013-07-10 14:38  yao2yao4  阅读(152)  评论(0编辑  收藏  举报

导航