private async void BtnCopyFolder_OnClick(object sender, RoutedEventArgs e) { if (dgUSB.SelectedItems.Count != 1) { MessageBox.Show(Localization.GetString("FrmUSBPrep", 37), Localization.GetString("Global", 68)); return; } var usb = (USBDrive)dgUSB.SelectedItems[0]; if (usb.Status != Status.Success) { MessageBox.Show(Localization.GetString("FrmUSBPrep", 38), Localization.GetString("Global", 68)); return; } var folderBrowserDialog = new FolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } Enable(false); await new TaskFactory().StartNew(() => { var copyDirectory = new CopyDirectory(folderBrowserDialog.SelectedPath, usb.Letter); copyDirectory.Status += CopyDirectoryOnStatus; copyDirectory.Run(); }).ContinueWith(delegate { lblStatus.UpdateText("Done"); Dispatcher.Invoke(() => { Enable(); }); }); }
public void Run(object ignore) { // We are in wind down mode, don't bother any more if (abandon) { return; } if (!copyTask.InProgress) { copyTask.Run(); } else { log.Info("Skipping directory synchronization, previous work still in progress: " + source); } }