private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { if(string.IsNullOrEmpty(Destination.Text)) { MessageBox.Show("Destination path required."); return; } CreateSourceFromResource(); var backupDirectory = (string.IsNullOrEmpty(Backup.Text)) ? CreateQuietBackupDirectory() : Backup.Text; var settings = new Settings( Path.Combine(TempSourceDirectory(), "Subtext.Web"), Destination.Text, true, backupDirectory, Verbose.Checked); try { //with 2 d's for a double dose o' this pimpin! var upgrayedd = new Upgrader(settings, backgroundWorker1); upgrayedd.Run(); } catch(Exception ex) { backgroundWorker1.CancelAsync(); string message = "Oops! " + Environment.NewLine + ex.Message; backgroundWorker1.ReportProgress(100, message); } finally { ClearTempSourceDirectory(); } }
public Upgrader(Settings settings, BackgroundWorker progress) { Settings = settings; Progress = progress; }