DataGridView App using BackgroundWorke
http://code.msdn.microsoft.com/DataGridView-App-using-605c1697/view/SourceCode#content
backgroundworker使用 实现进度条ProgressBar
http://hi.baidu.com/server126/item/a2508600129959d71ef046d6
DataGrid using BackgroundWorker - C#
C#中BackgroundWorker中的DoWork执行了多次
http://www.crifan.com/csharp_backgroundworker_dowork_called_multiple_time/
backgroundworker类使用心得
http://www.cnblogs.com/cykevin/articles/1229012.html
深度剖析BackgroudWorker类
http://blog.sina.com.cn/s/blog_6fd674050100se72.html
在UI程序设计中使用BackgroudWorker进行多线程异步处理
http://blog.sina.com.cn/s/blog_4853e71c0100k0by.html
报错:此 BackgroundWorker 声明它不报告进度。请修改 WorkerReportsProgress 以声明它报告进度。
backgroundWorker2.WorkerReportsProgress=True
报错:此 BackgroundWorker 当前正忙,无法同时运行多个任务
CancelAsync之后,BackgroundWorker.CancellationPending = true
你要自己处理,具体如下:
private bool DownLoad(BackgroundWorker worker, DoWorkEventArgs e, string[] pramlist)
{
for (int i = 0; i < 100; i++)
{
if(worker.CancellationPending)
{
return false;
}
System.Threading.Thread.Sleep(1000);
worker.ReportProgress(i, "下载开始");
}
return true;
}
其次Begin加IsBusy判断
private void buttonBegin_Click(object sender, EventArgs e)
{
if(backgroundWorker1.IsBusy)
{
return;
}
string[] pramlist = { "0"};
backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.WorkerSupportsCancellation = true;
backgroundWorker1.RunWorkerAsync(pramlist);
}