C#使用BackgroundWorker实现多线程

BackgroundWorker的对象定义:

this.backgroundWorker.WorkerSupportsCancellation = true;
            this.backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.DoWork);
            this.backgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.RunWokerCompeted);
         
private System.ComponentModel.BackgroundWorker backgroundWorker;

DoWork方法里包含了需要单开线程索要执行的操作动作。

该方法在BackgroundWorker.RunWorkerAsync()被调用时发生。

posted @ 2013-02-16 17:58  Qlx2011  阅读(328)  评论(0编辑  收藏  举报