在Silverlight中,你如何判断是否是code运行在UI线程与否? [英] In Silverlight, how do you find out whether the code is running in the UI thread or not?

查看:251
本文介绍了在Silverlight中,你如何判断是否是code运行在UI线程与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我需要知道是否我需要可以Dispatcher.BeginInvoke,或者如果它是没有必要的。

Basically I need to know whether I need to can Dispatcher.BeginInvoke or if it's not needed.

感谢。

推荐答案

您可以使用<一个href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.checkaccess%28VS.95%29.aspx"相对=nofollow> Dispatcher.CheckAccess 方法。如果你在同一个线程的UI调度它返回true,否则为假

You can use the Dispatcher.CheckAccess method. It returns true if you're on the same thread as the UI dispatcher, and false otherwise

这篇关于在Silverlight中,你如何判断是否是code运行在UI线程与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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