public void Run() { if (NumberOfImagesToExport <= 5) { BlockingOperation.Run(delegate { Export(null); }); Complete(); } else { ItemsToExport.ForEach(delegate(IClipboardItem item) { item.Lock(); }); BackgroundTask task = new BackgroundTask(Export, true) { ThreadUICulture = Application.CurrentUICulture }; ProgressDialogComponent progressComponent = new ProgressDialogComponent(task, true, ProgressBarStyle.Blocks); _progressComponentShelf = LaunchAsShelf(DesktopWindow, progressComponent, SR.TitleExportingImages, "ExportingImages", ShelfDisplayHint.DockFloat); _progressComponentShelf.Closed += delegate { Complete(); task.Dispose(); }; } }
private void Complete() { if (IsAsynchronous) { ItemsToExport.ForEach(delegate(IClipboardItem item) { item.Unlock(); }); } _progressComponentShelf = null; //notify the owner that we're done. _exportComponent.OnMultipleImageExportComplete(_error); _error = null; _taskContext = null; }