Writeablebitmap reading in an asynchronous call

I want to pass a writeablebitmap object generated from UI (WPF) into an asynchronous call but don't want to update the main thread's writeablebitmap. I just want to read some properties such as pixel height and width. In the new thread I can't access any of the writeablebitmap's properties since it thinks I'm trying to mess with the main thread's writeablebitmap's properties. I receive the exception: "The calling thread cannot access this object because a different thread owns it." Some responses in other threads suggested they use Dispatcher.BeginInvoke , but if I just want a copy of the writeablebitmap object to read data from, is this necessary?


Freezables lose their Thread-affinity when they're freezed. try calling Freeze() in the WritableBitmap.

Otherwise you can create a clone by using Clone() and then freeze the clone

链接地址: http://www.djcxy.com/p/26888.html

上一篇: 什么是HttpContext.Current.Request.RawUrl的WCF等价物?

下一篇: Writeablebitmap在异步调用中读取