摘要
委托是一种特殊的类,它将方法当作另一个方法的参数来进行传递,C#的事件、多线程等都是建立在委托机制的基础上。分析了在C#下委托的调用方式,同步调用容易理解,比较简单,但是容易引发阻塞,而异步调用比较抽象,但是能避免阻塞。通过实例,详细地分析了同步方式、基于IAsyncResult异步方式和基于事件的异步方式的差异,分析了网络编程下TCP传输的模式选择。
A delegate is a special class that method as a parameter to be passed to another method, C # events, multithreading, etc. are based on trust mechanism. This paper analyzes the invocation of delegate in C #, the synchronous call is easy to understand, relatively simple, but easily lead to obstruction, while an asynchronous call more abstract, but to avoid the obstruction, by example, a detailed analysis of the synchronous mode, based IAsyncResult asynchronous mode and differences in event-based asynchronous mode, the final analysis of TCP transport mode selection under networ k programming.
出处
《电脑编程技巧与维护》
2014年第6期9-11,共3页
Computer Programming Skills & Maintenance
关键词
同步方式
异步方式
多线程
委托
事件
Synchronous
Asynchronous mode
Multi-threading
Delegate
Events