How To Start And Stop A Continuously Running Background Worker Using A Button
问题 Let's say I have a background worker like this: private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { while(true) { //Kill zombies } } How can I make this background worker start and stop using a button on a WinForm? 回答1: This is how to do it (link to answer below) 回答2: Maybe you can use a manualresetevent like this, I didn't debug this but worth a shot. If it works you won't be having the thread spin its wheels while it's waiting ManualResetEvent run = new