在NET CF线程安全调用 [英] Thread-safe invoke on NET CF
问题描述
我有一个后台线程运行的触发事件,但我怎么能保证这些事件使用.NET CF中的一个线程安全的调用?
I have a background thread running that fires events, but how can I ensure a thread safe invocation of these events using NET CF?
我会用ISyncronizeInvoke在.NET平台上,但我不能找到这个在NET CF.我敢肯定有一个等效可用....还是?
I would use ISyncronizeInvoke on the NET platform, but I can't find this on NET CF. I'm sure there are an equivalent available.... or?
推荐答案
Compact Framework中的确实的有无 Control.Invoke
/ 的BeginInvoke
,但我相信这是受限于事件处理程序
委托(任何其他代表抛出一个异常,在执行期间)。
The Compact Framework does have Control.Invoke
/BeginInvoke
, although I believe it's limited to the EventHandler
delegate (with any other delegate throwing an exception at execution time).
假设你的实际的 ISynchronizeInvoke
的实例,将是一个UI控件,我只是通过引用作为控制
到任何需要它。如果你的真正的要使用的界面,你总是可以创建自己的 ISynchronizeInvoke
接口,然后它只是包装实施控制
。
Assuming your actual instance of ISynchronizeInvoke
is going to be a UI control, I'd just pass the reference as Control
to whatever needs it. If you really want to use an interface, you could always create your own ISynchronizeInvoke
interface, and then an implementation which just wraps Control
.
这篇关于在NET CF线程安全调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!