开发者

How does Silverlight Background Worker update the UI thread without problems?

I am using the Background worker thread in a Silverlight 4 application. In the ProgresssChanged event handler, I can make calls to the Silverlight UI, but how does this work ? Isn't the background worker thread that fires the ProgressChanged event on a different thread from the Silverlight UI thread ? If so, I thought updating the UI thread from another thread causes ex开发者_JAVA百科ceptions.

Scott


You're right that updating the UI Thread from another thread is a no-no. BackgroundWorker has special smarts to make sure, even though work is being done on a background thread, the ProgressChanged and RunWorkerCompleted events are raised on the UI Thread.

I believe it makes use of SynchronizationContext to do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜