public ShowAndDoWork ( Action |
||
work | Action |
|
Результат | void |
public void ShowAndDoWork(Action<IProgress> work)
{
_work = work;
Progress.ProgressIndicator = ProgressBar;
Progress.AddStatusProgress(_status);
Progress.AddMessageProgress(_messageLabelProgress);
Progress.Add(new ApplicationDoEventsProgress());//this will keep our UI alive
var stringProgress = new StringBuilderProgress();
Progress.Add(stringProgress);
Application.Idle += StartWorking;
ShowDialog();
if (Progress.ErrorEncountered)
{
SIL.Reporting.ErrorReport.NotifyUserOfProblem("There was a problem performing that operation.\r\n\r\n"+stringProgress.Text);
}
}
public void CopyImageMetadataToWholeBook(Metadata metadata) { using (var dlg = new ProgressDialogForeground())//REVIEW: this foreground dialog has known problems in other contexts... it was used here because of its ability to handle exceptions well. TODO: make the background one handle exceptions well { dlg.ShowAndDoWork(progress => CurrentBook.CopyImageMetadataToWholeBookAndSave(metadata, progress)); } }