.NET Framework - Do C# programmers use I/O Completion Ports directly?

Asked By James A. Fortune on 19-Jun-11 01:22 AM
In PDC 08 session TL21: WF 4.0: Extending with Custom Activities, Matt
Winkler demo'ed a parallel workflow and mentioned "I/O Completion
Ports."  I admit my ignorance of never having heard of them before
that.

From the MSDN entry for 'I/O Completion Ports':

http://msdn.microsoft.com/en-us/library/aa365198(v=vs.85).aspx

do so more quickly and efficiently by using I/O completion ports in
conjunction with a pre-allocated thread pool than by creating threads
at the time they receive an I/O request."

In one of the links from that entry:

http://blogs.msdn.com/b/oldnewthing/archive/2010/12/20/10107027.aspx

The first commenter (Anton Tykhyy) says:


Is using I/O Completion Ports in conjunction with a thread pool in C#
a good idea?  If so, is using C++ the best way to implement I/O
Completion Ports?

Thanks in advance,

James A. Fortune
CDMAPoster@FortuneJames.com




Peter Duniho replied to James A. Fortune on 19-Jun-11 01:43 AM
The comment you quote is trying to explain that when you use any of the
async versions of i/o APIs within .NET, the .NET Framework is using IOCP
in its implementation.

In other words, as long as you are using the async versions of the i/o
APIs (e.g. Stream.BeginRead(), Socket.BeginSend(), etc.), you get the
use of IOCP for free.  This includes the use of the thread pool to
process the i/o (in fact, the main System.Threading.ThreadPool class in
.NET includes support for both non-i/o and IOCP threads???they are
maintained in separate pools, but the same class handles both).

Pete
James A. Fortune replied to Peter Duniho on 19-Jun-11 01:53 AM
That's good news.  Thanks.

James A. Fortune
CDMAPoster@FortuneJames.com