Questions tagged «resharper-6.0»

3
当前的SynchronizationContext不能用作TaskScheduler
我正在使用Tasks在ViewModel中运行长时间运行的服务器调用,并且Dispatcher使用整理了结果TaskScheduler.FromSyncronizationContext()。例如: var context = TaskScheduler.FromCurrentSynchronizationContext(); this.Message = "Loading..."; Task task = Task.Factory.StartNew(() => { ... }) .ContinueWith(x => this.Message = "Completed" , context); 当我执行应用程序时,这工作正常。但是,当我运行NUnit测试时,Resharper我收到的错误消息FromCurrentSynchronizationContext为: 当前的SynchronizationContext不能用作TaskScheduler。 我猜这是因为测试是在工作线程上运行的。如何确保测试在主线程上运行?欢迎其他任何建议。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.