博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转载]:Invoke and BeginInvoke
阅读量:4508 次
发布时间:2019-06-08

本文共 1030 字,大约阅读时间需要 3 分钟。

8

To begin, from your link:

  • Control.Invoke: Executes on the UI thread, but calling thread waits for completion before continuing.
  • Control.BeginInvoke: Executes on the asynchronous UI thread, and calling thread doesn't wait for completion.

and from MSDN:

BeginInvoke executes the specified delegate asynchronously on the thread that the control's underlying handle was created on.

To sum it up, BeginInvoke is asynchronous. When BeginInvoke is called from the UI thread the request will be executed in parallel with the UI thread. Which means it may not execute until after the currently executing method has returned. So in this case the text box will never appear to update because the for loop will not be interrupted, as the calling thread will not wait for this event to be completed before continuing.

Alternatively, Invoke is synchronous. The text box will be updated because the calling thread will wait for the call to complete before continuing execution.

 

 

 

转载于:https://www.cnblogs.com/Jessy/archive/2011/09/07/2170010.html

你可能感兴趣的文章
PostgreSQL 利用pg_upgrade升级版本
查看>>
Mybatis分页插件PageHelper简单使用
查看>>
同步互斥——理发师睡觉问题
查看>>
Python编写的ARP扫描工具
查看>>
github之克隆
查看>>
IOS SWIFT基本画图教程
查看>>
Android 使用ContentProvider扫描手机中的图片,仿微信显示本地图片效果
查看>>
Android应用程序绑定服务(bindService)的过程源代码分析
查看>>
01背包问题,dp和贪心解法(c++11)
查看>>
PacificA协议小结
查看>>
android提示对话框
查看>>
OUC_Summer Training_ DIV2_#5
查看>>
java equals方法
查看>>
弧形菜单2(动画渐入)Kotlin开发(附带java源码)
查看>>
zabbix低级自动发现之mysql多实例
查看>>
实验六和实验十四
查看>>
用Swift重写公司OC项目(Day1)--程序的AppIcon与LaunchImage如何设置
查看>>
C++ 小的使用技巧和注意点
查看>>
x项目第一周随笔
查看>>
智能资产构建去中心化的资产管理系统
查看>>