Nadav said:
Thankd for your responce,
Well, I Would excpect that usage of a single IO completion port will
enable binding Stream objects ( e.g.
FileStream ) to the ThreadPool object ( which uses a single IO Completion
port ) preventing this, means that a
process that use a ThreadPool and a Stream object will utilize [AT-LEAST]
two Completion ports ( one for the
stream and one for the ThreadPool )... Enabling association of stream
objects with a ThreadPool will enable to
achieve better performence...
When you call BeginRead or BeginWrite you are binding to a thread pool but
the Framework does it all under the covers. The AsyncCallback method that
you pass to BeginRead or BeginWrite is called on a ThreadPool thread. You
can open a thousand streams and issue a thousand BeginReads and you WON'T
have a thousand threads waiting.
ThreadPool also has the BindHandle method that binds a handle to the
ThreadPool. This associates the handle with the ThreadPool's IO Completion
port. You usually don't want to use that, you should use
BeginRead/BeginWrite on a stream or, if you have a handle (i.e. to a named
pipe), create a FileStream with the constructor that takes a handle and set
the "isAsync" parameter to the constructor to true. That handle will be
bound to the ThreadPool's completion port and you can use
BeginRead/BeginWrite.
As far as I know, the ThreadPool only uses one IO Completion port. It might
use more than one if it is trying to optimize throughput, for example, it
might use one IO Completion port for every CPU. The important thing is that
you don't care, the Framework is doing the "right thing".