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 ...
随机推荐
- 21.scrapy爬虫部署
1.启用 scrapyd 2. 在浏览器打开127.0.0.1:6800/ 3. scrapy.cfg 设置 4. 遇到问题: scrapyd-deploy 不是内部命令 编辑 两个配置文件 @ech ...
- C# 设计模式-策略者模式(Strategy)
策略模式的用意是针对一组算法,将每一个算法封装到具有共同接口的独立的类中,从而使得它们可以相互替换.策略模式使得算法可以在不影响到客户端的情况下发生变化. 策略模式是对算法的包装,是把使用算法的责任和 ...
- 编写优秀Bug报告的艺术及案例分析
编写优秀Bug报告的艺术及案例分析 ---Rex Black原著<Fine art of writing a good bug report > ---Kiki翻译于2005/5/28 前 ...
- jsp中文乱码
<%@page pageEncoding="UTF-8"%> <meta http-equiv="Content-Type" content= ...
- Map 接口
1.键值对存储一组对象 2.key值不能重复,value可以重复 3.具体的实现类,HashMap,treeMap,HashTable,LinkedHashMap ------------------ ...
- VC 字符串转化和分割
原文:点击这里. 备忘:为了适用于Unicode环境,要养成使用_T()宏的习惯 1.格式化字符串 CString s;s.Format(_T("The num is %d."), ...
- VUE.js全局变量的定义
模块化之后,想用js全局变量,遇到点困难.搜索资料后搞定,大概2个步骤: 1.定义一个vue模块,const定义变量,并用export对外暴露. Globle.vue <script> / ...
- webpack环境搭建
环境搭建参考:Webpack+vue+element逐步搭建开发环境 webpack入门:http://www.jianshu.com/p/42e11515c10f ----------------- ...
- intellijIDEA Spring配置文件提示: File is included in 4 contexts
前提: 不影响编码,但是出现淡黄色的背景 解决办法: 打开Project Structure —> 选择Modules -> 选择Spring ->先点减号把之前的都删除掉 -> ...
- 1:python 简介与基础
什么是python? 1.python是一种面向对象的解释型语言,它继承了传统编译语言的通用性和强大性,同时也借鉴了简单脚本和解释语言的易用性. 2.python 在自动化测试.人工智能.数据分析等方 ...