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的更多相关文章

  1. Should I expose asynchronous wrappers for synchronous methods?

    Lately I've received several questions along the lines of the following, which I typically summarize ...

  2. [Chromium文档转载,第003章]Proposal: Mojo Synchronous Methods

    Proposal: Mojo Synchronous Methods yzshen@chromium.org 02/02/2016 Overview Currently there are quite ...

  3. Android JNI 学习(八):Calling Instance Methods Api

    一.GetMethodID jmethodIDGetMethodID(JNIEnv *env, jclass clazz, const char *name, const char *sig); 返回 ...

  4. Event 发布与订阅(一)

    前言 主要讲的是发布与订阅在Event中的一个简单实现用来加深理解. C #中的事件(Event)的理解: 事件具有以下属性:(From Events) 发行者确定何时引发事件:订户确定对事件作出何种 ...

  5. HttpWebRequest - Asynchronous Programming Model/Task.Factory.FromAsyc

    Posted by Shiv Kumar on 23rd February, 2011 The Asynchronous Programming Model (or APM) has been aro ...

  6. Should I expose synchronous wrappers for asynchronous methods?

    In a previous post Should I expose asynchronous wrappers for synchronous methods?, I discussed " ...

  7. C# to IL 8 Methods(方法)

    The code of a data type is implemented by a method, which is executed by the ExecutionEngine. The CL ...

  8. Calling a Java Method from Native Code

    http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/method.html Calling Java Method ...

  9. Extension Methods (C# Programming Guide)

    https://msdn.microsoft.com/en-us//library/bb383977.aspx private static void Dump(this ArraySegment&l ...

随机推荐

  1. Eureka 客户端启动报错误 Cannot determine embedded database driver class for database type NONE

    用这种数据库配置就是死活连不上数据库 提示:Cannot determine embedded database driver class for database type NONE 解决方式: 启 ...

  2. 框架: require.js

    require.js http://www.bootcdn.cn/require.js/ HTML: <div class="container" data-page=&qu ...

  3. Apache 服务器 基础知识小结

    Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软 ...

  4. django之paginator

    class Paginator(object):#分页器 def __init__(self, object_list, per_page, orphans=0, allow_empty_first_ ...

  5. Kali 局域网 DNS 劫持

    <一> 所需工具  1: Kali-linux-2017  2: ettercap 0.8.2 3: web 服务器, 这里以 node 为例 <二> 原理  1: DNS劫持 ...

  6. MonGoDB 在linux 上的安装和配置

    01: 下载 linux 版本的二进制包 => https://www.mongodb.com/ 02: 解压  => tar -zxf mongodb-linux-x86_64-3.4. ...

  7. HTML5 Canvas 小例子 伸缩旋转方块

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. 04.给linux用户添加sudo权限

    linux给用户添加sudo权限: 有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file.  This incident will be r ...

  9. Dom对象和jQuery对象的相互转化

    01.jQuery对象 1.jQuery对象就是通过对jQuery包装dom对象后产生的对象. 2.虽然jQuery对象是包装DOM对象后产生的,但是jQuery无法使用DOM对象的任何方法,同理DO ...

  10. 使用ssh密钥登录虚拟主机里的另一台主机报警的解决方案

    提示:Address 192.168.*.* maps to localhost, but this does not map back to the address - POSSIBLE BREAK ...