使线程安全调用Windows窗体控件 [英] Making thread-safe calls to windows forms controls

查看:118
本文介绍了使线程安全调用Windows窗体控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN文章:如何:使线程安全的调用到Windows窗体控件 说,我们应该使用异步委托来拨打电话。但为什么异步委托拨打电话安全吗?

The MSDN article: How to: Make Thread-Safe Calls to Windows Forms Controls says we should use async delegate to make the call. But why does the async delegate make the call safe?

推荐答案

Windows控件使用组件对象模型(COM)单线程单元(STA)模式,因为这些基本控件是单元线程。此外,许多控制用于许多操作消息泵。该模型认为,所有的函数调用每个控件必须在创建控件在同一个线程。调用(而BeginInvoke和EndInvoke)老帅方法调用适当的线程。

这是比尔·瓦格纳的更有效的C#。项目16.理解跨线程调用Windows窗体和WPF

From Bill Wagner's More Effective C#. Item 16. Understand Cross-Thread Calls in Windows Forms and WPF

这篇关于使线程安全调用Windows窗体控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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