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.
精彩评论