private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { //// UI control and background worker are different threads, in background worker, UI control is not allowed //// But it is allowed here, it belongs to the UI control thread measurementProgressBar.Value = e.ProgressPercentage; if (ImageInfo.phFlag) { DetectionResults.SetDetected("Phantom"); } if (ImageInfo.hcFlag) { DetectionResults.SetDetected("Tumor"); } if (ImageInfo.wtFlag) { DetectionResults.SetDetected("Water"); } if (ImageInfo.clFlag) { DetectionResults.SetDetected("Calcification"); } DataGridDetectionResult.ItemsSource = null; DataGridDetectionResult.ItemsSource = DetectionResults.Result; }