Exploring the depths and potentials of ASP.NET RSS 2.0 or Subscribe to .BenRush by Email
 Tuesday, July 17, 2007

MSDN Notes: Implementing the CLR Asynchronous Programming Model (Jeffrey Richter)

Source:
http://msdn.microsoft.com/msdnmag/issues/07/03/ConcurrentAffairs/

1.       Introduction

a.       For applications that require interaction with IO, the answer is often to write into the solution more threads – this still incurs an overhead, however, in terms of the operating system resources needed to spawn and manage threads.

b.      The better solution, according to this article, is to use the CLR’s Asynchronous Programming Model (APM) in lieu of the a more heavily threaded application.

c.       There are four main reasons, according to this article, why you would write a class that implements the APM.

                                                               i.      You’re building a class that directly interacts with hardware,

                                                             ii.      You might be building an abstraction layer atop a class or code base that already talks to hardware,

                                                            iii.      You may have long-running methods in your class,

                                                           iv.      You might be wrapping non-asynchronous Win32 functions.

2.       The heart of the APM: IAsyncResult

a.       Any class implementing APM has a Begin/End method (ex: BeginRead/EndRead) pair of methods. The Begin version must create and return an Iasyncresult object that is the center of APM model.

                                                               i.      The object can be queried for the status of the asynchronous operation and is used to determine the result when the operation is completed.

b.      IAsyncResult has a property – a wait handle – that is actually ineffecient to use and so ought to be avoided if at all possible (many asynchronous operations will have a callback anyway, signalling the end to the operation).

 

 

 


kick it on DotNetKicks.com
Tuesday, July 17, 2007 3:29:34 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
.Net Runtime | General .Net | MSDN Notes
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview

Computers Blogs - Blog Top Sites

Archive
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Benjamin Rush
Sign In
Statistics
Total Posts: 444
This Year: 0
This Month: 0
This Week: 0
Comments: 127
Themes
Pick a theme:
All Content © 2008, Benjamin Rush
DasBlog theme 'Business' created by Christoph De Baene (delarou)