views:

24

answers:

0

I have a BitmapSource that was created and frozen by a background thread.

On the UI thread I want to rotate the image and freeze it again (so the background thread can create thumbnails).

// transforming the image works
var img=new TransformedBitmap(Image, new RotateTransform(90));
// but Freeze is not allowed - will throw "The calling thread 
// cannot access this object because a different thread owns it."
img.Freeze(); 

Not sure if this is a bug or by design. As a workaround I could duplicate the image but to do that I first need to determine the owner of the image.

if (!img.CheckAccess())
   img=Util.CloneUnfreeze(img);

Unfortunately CheckAccess() will always return true because the image is frozen. Is there another way to check who owns an image? (I'd like to avoid a try/catch if possible)