在WP7应用程序中,我正在调用一些代码来从ScheduledAgent类的onInvoke方法更新实时磁贴.
In WP7 app I am calling some code to update a live tile from the onInvoke method on the ScheduledAgent class.
获取无效的跨线程错误.
Getting an invalid cross-thread error.
它失败的行是
var fontForeground = new SolidColorBrush(Colors.White);我知道在这个后台任务中无法调用ans API,但我仅尝试设置一些东西来生成自己的图像以显示在Live磁贴上.
I understand that there are limitations ans API's that I cannot call from within this background task, but I am only trying to setup some stuff to generate my own image to display on the Live tile.
这里有明显的地方我做错了吗?
Is there something obvious I am doing wrong here.
- 谢谢
更新...
我发现了这个问题
如何在Windows Phone 7中在后台线程的WriteableBitmap上呈现文本?
这是我遇到的同样的问题,尽管这里有一些很好的对话,但似乎没有一个简单的方法可以解决此问题?
It is the same issue that I have and whilst there is some good dialogue on here it doesn't appear that there is an easy way to get around this?
推荐答案使用Dispatcher在UI线程上而不是在后台线程上执行代码:
Use the Dispatcher to execute the code on the UI thread instead on a background thread:
Deployment.Current.Dispatcher.BeginInvoke(()=> { fontForeground = new SolidColorBrush(Colors.White); ... });更多推荐
WP7无效的跨线程访问
发布评论