65.9K
CodeProject is changing. Read more.
Home

Get the Silverlight Main Dispatcher before the RootVisual has been assigned

starIconstarIconstarIconstarIconstarIcon

5.00/5 (5 votes)

Feb 27, 2010

CPOL
viewsIcon

18581

Ordinarily the Application.Current.RootVisual.Dispatcher property is used to retrieve the System.Windows.Threading.Dispatcher for an application. Of course this won't work if performed before the RootVisual has been assigned. To get the Dispatcher for an application before the RootVisual has...

Ordinarily the Application.Current.RootVisual.Dispatcher property is used to retrieve the System.Windows.Threading.Dispatcher for an application. Of course this won't work if performed before the RootVisual has been assigned. To get the Dispatcher for an application before the RootVisual has been assigned, use the System.Windows.Deployment.Current.Dispatcher property. C#:
var dispatcher = Deployment.Current.Dispatcher;
VB.NET:
Dim dispatcher As Dispatcher = Deployment.Current.Dispatcher