为什么委托可以跨线程使用

flytigerme 2011-11-18 12:01:41
为什么委托可以跨线程使用
...全文
208 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
mabaolin 2011-11-18
  • 打赏
  • 举报
回复
本身不是异步调用,看谁调用了。
大蛮 2011-11-18
  • 打赏
  • 举报
回复
不知道 来学习
我记得线程本身就是调用一个委托的
机器人 2011-11-18
  • 打赏
  • 举报
回复
其实是回调啊。。。。
拿凤姐抵债 2011-11-18
  • 打赏
  • 举报
回复
没用过跨进程的。
委托是变量吗,还是类。
wjfwd2009 2011-11-18
  • 打赏
  • 举报
回复
还能夸进程使用呢
屿慕 2011-11-18
  • 打赏
  • 举报
回复
多线程可以同时访问一个字段,也可以同时调用一个委托。
宝_爸 2011-11-18
  • 打赏
  • 举报
回复
Control.Invoke Method (Delegate)

Executes the specified delegate on the thread that owns the control's underlying window handle.

来自:
http://msdn.microsoft.com/en-us/library/zyzhdc6b.aspx
宝_爸 2011-11-18
  • 打赏
  • 举报
回复
这个应该是原因吧

Updating user interface elements from a secondary thread in Windows Forms is tricky because a secondary thread is not allowed to read or write property values directly from a form or any of its child controls. This restriction exists because form objects and control objects in Windows Forms are not thread-safe. The only thread that's allowed to directly access a property value of a form or one of its controls is the primary UI thread. You must learn how to update the user interface without breaking this rule.

来自
http://msdn.microsoft.com/en-us/magazine/cc188732.aspx
宝_爸 2011-11-18
  • 打赏
  • 举报
回复
很好的问题,期待高手回答。
moxcm 2011-11-18
  • 打赏
  • 举报
回复
当做一个变量传递,肯定可以跨线程的
  • 打赏
  • 举报
回复
MultiCastDelegate

记得有个帖子讨论的是,为什么要弄一个handler中间变量来调用委托,而不是直接调用
委托跟线程似乎并没有直接关系吧,完全取决于应用场景
期待P哥的答复
铜臂阿铁木 2011-11-18
  • 打赏
  • 举报
回复
委托也没有跨线程使用啊……委托可以这么理解:将事情委托给主线程去执行,什么时候执行,要看主线程什么时候有空,什么时候心情好……

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧