c# wpf Updating UI source from BlockingCollection with Dispatcher
问题 Here's my problem. I'm loading a few BitmapImages in a BlockingCollection public void blockingProducer(BitmapImage imgBSource) { if (!collection.IsAddingCompleted) collection.Add(imgBSource); } the loading happens in a backgroungwork thread. private void worker_DoWork(object sender, DoWorkEventArgs e) { String filepath; int imgCount = 0; for (int i = 1; i < 10; i++) { imgCount++; filepath = "Snap"; filepath += imgCount; filepath += ".bmp"; this.Dispatcher.BeginInvoke(new Action(() => { label1