locked
Frequent exception generated by BitmapFrame.GetPixelDataAsync(...) RRS feed

  • Question

  • The following exception occurs frequently when  BitmapFrame.GetPixelDataAsync(BitmapPixelFormat, BitmapAlphaMode, BitmapTransform, ExifOrientationMode, ColorManagementMode) | getPixelDataAsync(BitmapPixelFormat, BitmapAlphaMode, BitmapTransform, ExifOrientationMode, ColorManagementMode) is called:

    System.Exception was caught
      HResult=-2147024093
      Message=The handle with which this oplock was associated has been closed.  The oplock is now broken. (Exception from HRESULT: 0x80070323)
      Source=mscorlib
      StackTrace:
           at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
           at My_App.MainPage.<FooAsync>d__3c.MoveNext() in e:\Users\xxx\Documents\xxx\MainPage.xaml.cs:line 734
      InnerException: 
    

    The instance of BitmapFrame calling this method appears to be fine when this happens.  It seems to be random, not associated with any specific images. 

    Any tip to help understand this will be greatly appreciated. 


    Hong

    Saturday, January 25, 2014 2:11 PM

Answers

  • This exception can occurs if you try to access to the image stream from an other part of your code at the same time.

    Did you try to execute the same code from an another thread ? Did you close your stream between two access?

    • Marked as answer by Hong (MA, USA) Saturday, January 25, 2014 3:13 PM
    Saturday, January 25, 2014 3:04 PM

All replies

  • This exception can occurs if you try to access to the image stream from an other part of your code at the same time.

    Did you try to execute the same code from an another thread ? Did you close your stream between two access?

    • Marked as answer by Hong (MA, USA) Saturday, January 25, 2014 3:13 PM
    Saturday, January 25, 2014 3:04 PM
  • Thank you for your prompt response.  It appears to have something to do with file access though I am yet to understand it fully.  I have code like the following:

    using (IRandomAccessStream fileStream = await sfCurrent.OpenAsync(Windows.Storage.FileAccessMode.Read))
    {
      // instantiate a BitmapDecoder with fileStream 
    }

    It seems the BitmapDecoder still needs to access the file after the using block. I am puzzled. 


    Hong

    Saturday, January 25, 2014 3:19 PM