Can't use dispatcher on WP7

断了今生、忘了曾经 提交于 2019-12-20 09:39:13

问题


I was looking around for refrences using dispatcher to call code on the UI thread and they say to do this:

Dispatcher.BeginInvoke(() => {OnSendSuccessful(); });

But I get a compiler error saying I cant access non-static method BeginInvoke in a static context. Any ideas? I tried to new up a dispatcher but that doesn't even make sense.


回答1:


Try using:

Deployment.Current.Dispatcher.BeginInvoke(() => {OnSendSuccessful(); });  

This uses a static method to get a dispatcher for use in a static context.



来源:https://stackoverflow.com/questions/4247729/cant-use-dispatcher-on-wp7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!