void view_SyncRequested(object sender, SyncRequestEventArgs e) { if (syncIsOn) { MessageBox.Show( "Another synchrinization is in progress. Wait untill it is over."); return; } ThreadPool.QueueUserWorkItem(delegate { syncIsOn = true; var sync = new Synchronizer(new SyncTarget(e.PathA, e.PathB)); sync.ProgressUpdated += sync_ProgressUpdated; try { sync.Synchronize(); view.ShowMessage("Done"); } catch (Exception ex) { view.ShowMessage("Failed with exception " + ex); } view.UpdateFileList(FolderRepresentPosition.A, FileEditor.GetFiles(e.PathA)); view.UpdateFileList(FolderRepresentPosition.B, FileEditor.GetFiles(e.PathB)); sync.ProgressUpdated -= sync_ProgressUpdated; syncIsOn = false; }); }
private void buttonSync_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBoxPathA.Text)) { MessageBox.Show("Enter first folder to synchronize."); return; } if (string.IsNullOrWhiteSpace(textBoxPathB.Text)) { MessageBox.Show("Enter second folder to synchronize."); return; } var args = new SyncRequestEventArgs(textBoxPathA.Text, textBoxPathB.Text); var handler = SyncRequested; if (handler != null) { handler(this, args); } }