Initializing the DispatcherHelper for WP7 - where?

Aug 8, 2010 at 9:26 AM

The docs say to initialise the DispatcherHelper during Application_Startup when the MainPage is assigned to the Root Visual. In the latest MVVM light the RootVisual is assigned in  


However the comment says

// Do not add any additional code to this method

I have ignored this comment for now and added the following after the RootVisual is assigned: DispatcherHelper.Initialize();

Any thoughts on where this should really go?

BTW If you don't initialise this you get a NullReferenceException when calling

CheckBeginInvokeOnUI (might be nice if MVVM Light checked for this in debug mode and put out some helpful hint about intitialising the DispatcherHelper).

Aug 11, 2010 at 9:11 AM
I was clearly being stupid, you can obviously subscribe to Startup in the App constructor: this.Startup += new StartupEventHandler(App_Startup);