private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { // Get the BackgroundWorker that raised this event. BackgroundWorker worker = sender as BackgroundWorker; CredentialsGetter credential = new CredentialsGetter(); ZucchettiPageDownloader downloader = new ZucchettiPageDownloader(); TimbratureBuilder localtimbrature = new TimbratureBuilder(Utils.getFirstWorkingDayOfWeekAsDate(dateTimePicker.Value.Date)); var collection = downloader.DownloadTimbratureCurrentMonth(credential.GetUser(), credential.GetPassword(), (DateTime)e.Argument, localtimbrature, worker); e.Result = localtimbrature; downloader.Cleanup(); }
private void downloadButton_Click(object sender, EventArgs e) { // Assign the result of the computation // to the Result property of the DoWorkEventArgs // object. This is will be available to the // RunWorkerCompleted eventhandler. CredentialsGetter credential = new CredentialsGetter(); if (!credential.HasValidCredentials()) { PickCredentialForm form = new PickCredentialForm(); form.Show(); return; } downloadButton.Enabled = false; resultTextBox.Text = "Downloading..."; DateTime date = dateTimePicker.Value.Date; backgroundWorker.RunWorkerAsync(date); }