Calling Synchronous Methods Asynchronously
【Calling Synchronous Methods Asynchronously】
使用 .NET Framework 可以以异步方式调用任何方法。 要实现此操作,请定义一个委托,此委托具有与你要调用的方法相同的签名;公共语言运行时会自动使用适当的签名为此委托定义 BeginInvoke 和 EndInvoke 方法。
BeginInvoke 方法启动异步调用。 该方法具有与你要异步执行的方法相同的参数,另加两个可选参数。 第一个参数是一个 AsyncCallback 委托,此委托引用在异步调用完成时要调用的方法。 第二个参数是一个用户定义的对象,该对象将信息传递到回调方法。 BeginInvoke 将立即返回,而不会等待异步调用完成。 BeginInvoke 返回可用于监视异步调用的进度的 IAsyncResult。
EndInvoke 方法用于检索异步调用的结果。 它可以在调用 BeginInvoke 之后的任意时间调用。 如果异步调用尚未完成,那么 EndInvoke 将阻止调用线程,直到完成异步调用。 EndInvoke 的参数包括您需要异步执行的方法的 out 和 ref 参数(在 Visual Basic 中为 <Out> ByRef 和 ByRef)以及由 IAsyncResult 返回的 BeginInvoke。
参考:https://msdn.microsoft.com/zh-cn/library/2e08f6yc(v=vs.110).aspx
Calling Synchronous Methods Asynchronously的更多相关文章
- Should I expose asynchronous wrappers for synchronous methods?
Lately I've received several questions along the lines of the following, which I typically summarize ...
- [Chromium文档转载,第003章]Proposal: Mojo Synchronous Methods
Proposal: Mojo Synchronous Methods yzshen@chromium.org 02/02/2016 Overview Currently there are quite ...
- Android JNI 学习(八):Calling Instance Methods Api
一.GetMethodID jmethodIDGetMethodID(JNIEnv *env, jclass clazz, const char *name, const char *sig); 返回 ...
- Event 发布与订阅(一)
前言 主要讲的是发布与订阅在Event中的一个简单实现用来加深理解. C #中的事件(Event)的理解: 事件具有以下属性:(From Events) 发行者确定何时引发事件:订户确定对事件作出何种 ...
- HttpWebRequest - Asynchronous Programming Model/Task.Factory.FromAsyc
Posted by Shiv Kumar on 23rd February, 2011 The Asynchronous Programming Model (or APM) has been aro ...
- Should I expose synchronous wrappers for asynchronous methods?
In a previous post Should I expose asynchronous wrappers for synchronous methods?, I discussed " ...
- C# to IL 8 Methods(方法)
The code of a data type is implemented by a method, which is executed by the ExecutionEngine. The CL ...
- Calling a Java Method from Native Code
http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/method.html Calling Java Method ...
- Extension Methods (C# Programming Guide)
https://msdn.microsoft.com/en-us//library/bb383977.aspx private static void Dump(this ArraySegment&l ...
随机推荐
- 《机器学习实战》AdaBoost算法(手稿+代码)
Adaboost:多个弱分类器组成一个强分类器,按照每个弱分类器的作用大小给予不同的权重 一.Adaboost理论部分 1.1 adaboost运行过程 注释:算法是利用指数函数降低误差,运行过程通过 ...
- mysql中的sql_mode
mysql数据库的中有一个环境变量sql_mode,定义了mysql应该支持的sql语法,数据校验等!我们可以通过以下方式查看当前数据库使用的sql_mode: mysql> select @@ ...
- glob获取指定目录下的东西+更改工作目录
一:不更改工作目录 import glob path = 'image/imgs/*.jpg' # 正则匹配 指定路径 file_path = glob.glob(path) # 即可获取所有jpg的 ...
- 12. ajax、datagrid请求传参实例
############实例1:############ var data = {};data.orgRoleCode = orgRoleCode;data.orgRoleName = orgRole ...
- MySQL5.7.20 二进制包无ROOT权限下安装, 滴滴云服务器
01, 下载安装包 => https://dev.mysql.com/downloads/mysql/ 02, 上传到linux系统, 笔者这里使用的 滴滴云服务器 安装在 home/dc2- ...
- 使用Prometheus+Grafana监控MySQL实践
一.介绍Prometheus Prometheus(普罗米修斯)是一套开源的监控&报警&时间序列数据库的组合,起始是由SoundCloud公司开发的.随着发展,越来越多公司和组织接受采 ...
- js 只允许输入数字
<input id="credit" type="text" class="nummber" onkeyup="value= ...
- 企业微信二次开发之-如何获取secret序列号
第一步:登录JEEWX后台,配置微信企业号账号信息(企业号.企业号应用) [1].配置企业微信信息 参数对应位置参考如下: [2].配置应用信息 必须四字段: 第二步: 登录企业微信后台,配置企业号应 ...
- keyword模块
导入关键字模块 import keyword 列出当前系统中Python的关键字 >>> keyword.kwlist ['and', 'as', 'assert', 'break' ...
- python-玉米(小米)商城作业
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...