为什么我在窗体应用里定义的backgroundWorker不顶用?求大佬帮看看哪里有问题?
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i <= 100; i++)
{
if (backgroundWorker1.CancellationPending)
{
e.Cancel = true;
return;
}
else
{
contentShow.Items.Insert(0, "123");
System.Threading.Thread.Sleep(100);
}
}
}
private void button1_Click(object sender, EventArgs e)
{
//if (backgroundWorker1.IsBusy)
// return;
backgroundWorker1.RunWorkerAsync();
//backgroundWorker1.RunWorkerAsync();
//AnalyzeJudgement();
}