Asynchronous Method Invocation 【翻译】 (五)
来源:互联网 发布:淘宝查虚假交易时间 编辑:程序博客网 时间:2024/05/21 07:47
Using the Callback delegate, Hollywood style "Don�t call me I will call you!"
At this point, you should understand how parameters can be passed, how to pass state, and understand the fact that your method is executed on a thread within the ThreadPool
. The only thing I didn�t really cover is the idea of being notified when the method is finished executing. After all, blocking and waiting for the method to finish does not accomplish much. In order to be notified when a method is complete, you must supply a callback delegate on the BeginInvoke
. OK, example! Look at the following two functions:
使用委托回调,就像好莱坞的风格"Don't call me I will call you!"
我们应该理解了参数怎么传递,状态怎么传递,理解了方法如何在线程池里的执行。唯一没有提到的是方法执行完毕时,我们怎么被通知到。
毕竟,阻塞和等待方法的完成,并不那么好搞。当一个方法完成,我们要被通知到的话,你必须在BeginInvoke上提供一个回调委托。好吧,例子说明!看下下面的2个函数:
In here, you can see that we passed a delegate to the function CallBack
when calling BeginInvoke
. .NET will call us when the method FooWithOutAndRefParameters
completes execution. As before, we all know that we must call EndInvoke
if we want to get our output parameters. Notice that in order to call EndInvoke
, I needed to do some gymnastics to get the delegate.
在这里,我们可以了解到,当调用BeginInvoke时候,我们传递一个委托回调CallBack函数。当FooWithOutAndRefParameters完全执行完毕,.NET将会通知我们。在这之前,如果我们想获得输出参数,我们必须调用EndInvoke。注意到,想要调用EndInvoke我需要做些操作来获取委托。
- Asynchronous Method Invocation 【翻译】 (五)
- Asynchronous Method Invocation 【翻译】 (一)
- Asynchronous Method Invocation 【翻译】 (二)
- Asynchronous Method Invocation 【翻译】 (三)
- Asynchronous Method Invocation 【翻译】 (四)
- Asynchronous Method Invocation 【翻译】 (六)
- Asynchronous Method Invocation
- Asynchronous Method Invocation
- Asynchronous Method Invocation
- Asynchronous Method的理解
- Java Remote Method Invocation
- RMI(Remote Method Invocation)
- Remote Method Invocation
- method invocation of interface
- RMI remote method invocation
- RMI:remote method invocation
- Remote Method Invocation (RMI)
- java method invocation demo
- 纯源码包安装 lua 的时候遇到的错误和解决办法~~~
- GetDlgItem函数 返回某个控件的的句柄。
- 6-3 分隔控件(Splitters) 收藏
- 使用Config::IniFiles读写ini文件
- [转][译]BigPipe:高性能的“流水线技术”网页
- Asynchronous Method Invocation 【翻译】 (五)
- php的autoprepend和autoload功能
- 今天被WINDOWS的防火墙给撞了一下腰,不要告诉我你懂WINDOWS的防火墙!!!!
- 预处理器
- Qt控件拖拽事件
- 分布式文件系统FastDFS架构剖析
- Android MK文件写法
- 视频序列分辨率-视频测试序列的下载地址
- 触摸屏网摘