3 回答

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊
private bool closePending;protected override void OnFormClosing(FormClosingEventArgs e) { if (backgroundWorker1.IsBusy) { closePending = true; backgroundWorker1.CancelAsync(); e.Cancel = true; this.Enabled = false; // or this.Hide() return; } base.OnFormClosing(e);}void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (closePending) this.Close(); closePending = false; // etc...}

TA貢獻(xiàn)2080條經(jīng)驗(yàn) 獲得超4個(gè)贊
List<Thread> bgWorkersThreads = new List<Thread>();
bgWorkesThreads.Add(Thread.CurrentThread);
foreach (Thread thread in this.bgWorkersThreads) { thread.Abort(); }
CustomTaskPane
COM Exception
CancelAsync()
backgroundworkers
DocumentBeforeClose
- 3 回答
- 0 關(guān)注
- 425 瀏覽
添加回答
舉報(bào)