不能在WP7上使用调度程序 [英] Can't use dispatcher on WP7

查看:64
本文介绍了不能在WP7上使用调度程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找使用调度程序在UI线程上调用代码的伪造品,他们说要这样做:

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

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

但是我收到一个编译器错误,说我无法在静态上下文中访问非静态方法BeginInvoke。有任何想法吗?我试图新建一个调度程序,但这甚至没有意义。

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.

推荐答案

尝试使用:

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

这使用静态方法来获取在静态上下文中使用的调度程序。

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

这篇关于不能在WP7上使用调度程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆