I have a loop in Background worker in a Winform Application.
I Just used this Code but it won\'t resume after the Pause.
In the main Class I use this
My best guess for what you want:
void ResumeWorker() {
// Start the worker if it isn't running
if (!backgroundWorker1.IsBusy) backgroundWorker1.RunWorkerAsync(tempCicle);
// Unblock the worker
_busy.Set();
}
void PauseWorker() {
// Block the worker
_busy.Reset();
}
void CancelWorker() {
if (backgroundWorker1.IsBusy) {
// Set CancellationPending property to true
backgroundWorker1.CancelAsync();
// Unblock worker so it can see that
_busy.Set();
}
}