private void takePageScreenshotBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; if (worker.CancellationPending == true) { return; } presenter.TakeAndSaveScreenshot(); }
private async void btnTakePageScreenshot_Click(object sender, EventArgs e) { btnTakePageScreenshot.Enabled = false; var oldBackground = btnTakePageScreenshot.BackColor; btnTakePageScreenshot.BackColor = Color.DarkGray; try { presenter.DisplayLoadingIndicator(true); await presenter.TakeAndSaveScreenshot(); } finally { btnTakePageScreenshot.Enabled = true; btnTakePageScreenshot.BackColor = oldBackground; presenter.DisplayLoadingIndicator(false); } }