public void ShowProgressForm(Action Start = null, Action Complete = null) { var ProgressForm = new ProgressForm(); ProgressForm.WaitObject = this.IsFinishedLockObject; this.OnStep += delegate(double Value, String Details) { ProgressForm.SetStep(Value, Details); }; ProgressForm.SetOriginDestination( SourceFileSystem.Title, DestinationFileSystem.Title ); this.OnError += delegate(Exception Exception) { if (!Canceling) { MessageBox.Show(Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }; ProgressForm.OnCancelClick = delegate() { return(MessageBox.Show("¿Está seguro de querer cancelar la sincronización?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes); }; if (Complete != null) { ProgressForm.Complete += Complete; } ProgressForm.Process = delegate() { RetrySource: try { CallStep(0, String.Format(ConnectingToFormat, SourceFileSystem.Title)); SourceFileSystem.TryInitialize(); } catch (Exception Exception) { Console.WriteLine(Exception); if (!Canceling) { if (MessageBox.Show(Exception.Message + "\n\n" + Exception.StackTrace, "Can't connect to local FileSystem", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Retry) { goto RetrySource; } } } RetryDestination: try { CallStep(0, String.Format(ConnectingToFormat, DestinationFileSystem.Title)); DestinationFileSystem.TryInitialize(); } catch (Exception Exception) { Console.WriteLine(Exception); if (!Canceling) { if (MessageBox.Show(Exception.Message + "\n\n" + Exception.StackTrace, "Can't connect to remote FileSystem", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Retry) { goto RetryDestination; } } } Console.WriteLine("Started SynchronizeFolder ({0} -> {1})...", SourceFileSystem, DestinationFileSystem); this.SynchronizeFolder(); }; ProgressForm.Cancel = this.Cancel; if (Start != null) { Start(); } //ProgressForm.ShowDialog(); ProgressForm.ExecuteProcess(); }