Received what at the time seemed like a strange exception from a piece of code in a silverlight I was debugging yesterday - 'this operation can only occur on the ui thread.'
What makes this strange was the fact this wasn't attempting to update any UI controls or classes bound to views, infact this was the complete opposite, this was a method trying to invoke out to javascript from a randomly assigned thread (thread pool). To compound my confusion not only was I seeing this intermittently but the action I was trying to achieve still appeared to completely successfully, writing to an in-memory javascript log!
Now the answer is as you probably known, is...
Any interaction with the host browser from silverlight has to be done on the UI thread even if you're not updating any UI.
What makes this strange was the fact this wasn't attempting to update any UI controls or classes bound to views, infact this was the complete opposite, this was a method trying to invoke out to javascript from a randomly assigned thread (thread pool). To compound my confusion not only was I seeing this intermittently but the action I was trying to achieve still appeared to completely successfully, writing to an in-memory javascript log!
Now the answer is as you probably known, is...
Any interaction with the host browser from silverlight has to be done on the UI thread even if you're not updating any UI.
Comments
Post a Comment