I am using the SL unit test framework for tests (http://code.msdn.microsoft.com/silverlightut). My code is heavily client-server co开发者_StackOverflow社区mmunications dependant, and I access the GUI dispatcher in several places to make sure important data is only accessed on a single thread (ie. the GUI thread).
This dispatcher seems unavailable in the unit tests - I have tried using Deployment.Current.Dispatcher and even created an instance of a blank control to try use its own dispatcher, but both don't work. The code inside of Dispatcher.BeginInvoke() just never executes, even if I include a Thread.Sleep afterwards.
I had to add references to System.Deployment and other testing libraries for Deployment.Current.Dispatcher to work.
It works fine now.
精彩评论