private void InitComposer(IBackgroundTaskContext context) { const float WGT_SCAN = 10f; const float WGT_INIT = 90f; List <IPresentationImage> queue = new List <IPresentationImage>(); int count = 0; int total = this.Context.ClipboardItems.Count; context.ReportProgress(new BackgroundTaskProgress(0, SR.MessageScanningClipboard)); foreach (IClipboardItem item in this.Context.ClipboardItems) { if (item.Item is IPresentationImage) { Enqueue(queue, (IPresentationImage)item.Item); } else if (item.Item is IDisplaySet) { Enqueue(queue, (IDisplaySet)item.Item); } else if (item.Item is IImageSet) { Enqueue(queue, (IImageSet)item.Item); } count++; if (context.CancelRequested) { break; } context.ReportProgress(new BackgroundTaskProgress((int)(WGT_SCAN * count / total), SR.MessageScanningClipboard)); } if (!context.CancelRequested) { StudyComposerComponent composer = new StudyComposerComponent(); total = queue.Count; for (int n = 0; n < queue.Count; n++) { if (context.CancelRequested) { break; } IPresentationImage image = queue[n]; context.ReportProgress(new BackgroundTaskProgress((int)(WGT_SCAN + WGT_INIT * n / total), SR.MessageReadingImages)); composer.InsertImage(image); } if (!context.CancelRequested) { context.ReportProgress(new BackgroundTaskProgress(100, SR.Done)); _composer = composer; context.Complete(null); } } if (context.CancelRequested) { context.Cancel(); } }