开发者

How to access Dispatcher in Silverlight tests?

开发者 https://www.devze.com 2022-12-11 13:26 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消