Cancelling Background Tasks
问题 When my C# application closes it sometimes gets caught in the cleanup routine. Specifically, a background worker is not closing. This is basically how I am attempting to close it: private void App_FormClosing(object sender, FormClosingEventArgs e) { backgroundWorker1.CancelAsync(); while (backgroundWorker1.IsBusy) ; // Gets stuck here. } Is there a different way that I should be doing this? I am using Microsoft Visual C# 2008 Express Edition. Thanks. ADDITIONAL INFORMATION: The background