private void cancel_Click(object sender, EventArgs e) { if (FindServicesWorker.IsBusy) { FindServicesWorker.CancelAsync(); } //CleanUp(); }
private void ServiceSelectionDialog_FormClosing(object sender, FormClosingEventArgs e) { this.FindServicesWorker.RunWorkerCompleted -= this.FindServicesWorker_RunWorkerCompleted; this.FindServicesWorker.ProgressChanged -= this.FindServicesWorker_ProgressChanged; if (FindServicesWorker.IsBusy) { FindServicesWorker.CancelAsync(); } }
// use from _DoWork like so: // if (!ReportProgressIfNotCancelled(...)) { return; } private Boolean ReportProgressIfNotCancelled(int progress, Object message) { if (FindServicesWorker.CancellationPending) { return(false); } else { FindServicesWorker.ReportProgress(progress, message); return(true); } }
internal void FindServices() { FindServicesWorker.RunWorkerAsync(); timer.Start(); }