void MultimediaThumbnailViewer_Loaded(object sender, RoutedEventArgs e) { var service = new SupportService(PluginManager.Instance.User); if (_model == null) { using (new OverrideCursor(Cursors.Wait)) { if (ReportData != null && ReportData.ContainsColumn("MultimediaLink")) { int index = ReportData.IndexOf("MultimediaLink"); _model = new ObservableCollection <MultimediaLinkViewModel>(); foreach (MatrixRow row in ReportData) { var link = row[index] as MultimediaLink; if (link != null) { _model.Add(new MultimediaLinkViewModel(link)); } } this.thumbList.ItemsSource = _model; } } lock (_model) { if (!_threadRunning) { _threadRunning = true; JobExecutor.QueueJob(() => { if (_model != null) { if (Progress != null) { Progress.ProgressStart("Generating thumbnails..."); } int count = 0; foreach (MultimediaLinkViewModel vm in _model) { bool generate = false; vm.InvokeIfRequired(() => { generate = vm.Thumbnail == null; }); if (generate) { GenerateThumbnail(vm, THUMB_SIZE); } count++; if (Progress != null) { double percent = (((double)count) / ((double)_model.Count)) * 100.0; Progress.ProgressMessage(string.Format("Generating thumbnails ({0} of {1})", count, _model.Count), percent); } } if (Progress != null) { Progress.ProgressEnd(string.Format("{0} thumbnails generated", count)); } } _threadRunning = false; }); } } } }