예제 #1
0
 private void CreateBitmapAndAddToProcessingCollection(string name)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         var uri = new Uri(name);
         var image = new BitmapImage(uri);
         image.Freeze();
         PendingImages.Add(image);
         _blockingCollection.Add(image);
     }), DispatcherPriority.Background);
 }
예제 #2
0
 private void ProcessBitmaps(CancellationToken token)
 {
     while (!token.IsCancellationRequested)
     {
         BitmapImage image;
         try
         {
             image = _blockingCollection.Take(token);
         }
         catch (OperationCanceledException)
         {
             return;
         }
         FormatConvertedBitmap grayBitmapSource = ConvertToGrayscale(image);
         Dispatcher.BeginInvoke((Action)(() =>
         {
             ProcessedImage = grayBitmapSource;
             PendingImages.Remove(image);
         }));
         Thread.Sleep(1000);
     }
 }