Sometimes when we try to update UI elements from a different thread in Silverlight( asynchronous callbacks such as xml, json, WCF), we will run into invalid cross-thread access error if a “Dispatcher.BeginInvoke” is not used.

In most cases we can use the following and it will work fine.

this.Dispatcher.BeginInvoke(delegate()
            {
                //do something here
            });

However, this won’t work on static functions/methods, because for the most obvious reason, “this” can not be used in static function.

System.Windows.Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                   //do something here
                });
Tags
Comments
Write the first comment
Leave a trace
Name *
Email *
Website
Anti SPAM * Code (8 + 6) =
Leave me a comment *
 
All comments are subject to editorial review
Post being viewed right now
Item date: 13.05.2009
Views: 1456
Item date: 18.06.2009
Views: 1899
Item date: 27.09.2009
Views: 1947
Item date: 14.07.2010
Views: 2343
Item date: 21.07.2009
Views: 501
Item date: 23.03.2009
Views: 1407974
Item date: 09.10.2009
Views: 538
Item date: 23.08.2009
Views: 2343
Item date: 27.09.2009
Views: 1279