private void Window_Loaded(object sender, RoutedEventArgs e) { BuildCanvas(); #region Load Models ProgressReporter progressReporterModels = new ProgressReporter(); taskLoadModels = Task.Factory.StartNew(() => { return(ms.LoadModels()); }); progressReporterModels.RegisterContinuation(taskLoadModels, () => { if (taskLoadModels.Exception != null) { statusBar.Text = "Models loaded: " + taskLoadModels.Result.Count; } else if (taskLoadModels.IsCanceled) { } else //all OK { if (taskLoadModels.Result != null && taskLoadModels.Result.Count > 0) { statusBar.Text = "Models loaded: " + taskLoadModels.Result.Count; listModels.DataContext = taskLoadModels.Result; listModels.ItemsSource = taskLoadModels.Result; } else { statusBar.Text = "No models loaded."; } } }); #endregion progressReporterClassification = new ProgressReporter(); }