One of the coolest features in Silverlight is UI threading. WPF is also provides UI threading. I got to know about this feature while I was trying to update the UI elements from my background thread. After googling around I saw a nice class that deals with threading which is the Dispatcher class. Mainly what Dispatcher class does is it provides services for managing the queue of work items for a thread.
One important thing that you should keep in your mind is that Silverlight recognizes the difference between UI threads and background threads. You just can't update controls designed in XAML through your background thread. You must invoke the UI thread by using the Dispatcher class.
We can simply do this by declaring a delegate to access the XAML DOM.
Dispatcher.BeginInvoke(delegate()
{
//update the UI
});
Happy Coding.
Regards,
Jaliya
No comments:
Post a Comment