How to wait for a BackgroundWorker to cancel?
问题 Consider a hypothetical method of an object that does stuff for you: public class DoesStuff { BackgroundWorker _worker = new BackgroundWorker(); ... public void CancelDoingStuff() { _worker.CancelAsync(); //todo: Figure out a way to wait for BackgroundWorker to be cancelled. } } How can one wait for a BackgroundWorker to be done? In the past people have tried: while (_worker.IsBusy) { Sleep(100); } But this deadlocks, because IsBusy is not cleared until after the RunWorkerCompleted event is