相当于InvokeRequired在WPF [英] Equivalent to InvokeRequired in WPF
本文介绍了相当于InvokeRequired在WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个相当于Form.InvokeRequired在WPF中,例如?Dispatcher.InvokeRequired
Is there an equivalent to Form.InvokeRequired in WPF, e.g. Dispatcher.InvokeRequired?
推荐答案
,因为它不会出现在智能感知,但你可以使用这是有点奇怪:
This is slightly odd as it doesn't appear in intellisense, but you can use:
var dispatcher = myDispatcherObject.Dispatcher;
if (dispatcher.CheckAccess()) { /* ... */ }
由于所有UI组件从 DispatcherObject的
继承这个应该解决您的具体问题,但它不是具体到UI线程 - 它可以被用于任何调度
As all UI components inherit from DispatcherObject
this should solve your specific problem, but it is not specific to the UI thread - it can be used for any dispatcher.
这篇关于相当于InvokeRequired在WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文