Peter Duniho
10/10/2008 11:13:00 AM
On Fri, 10 Oct 2008 01:12:01 -0700, PFx <PFx@discussions.microsoft.com>
wrote:
> Thanks for your advice.
> It 's exactly what I ended with.
>
> But I am still confused with the 'maxNumberOfServerInstances'-parameter
> in the constructor. If > 1, how does it map to threads? I still have to
> create some more background-threads and an equal number of
> pipe-instances for
> my multithreaded-listener-application (?).
> Documentation and community-info about this topic is quite sparse ...
Unfortunately, named pipes support is brand-new in .NET, and so it's
likely information on the specifics will be sparse for the near future.
I myself have very little knowledge of it. I would say that for the most
part, you should not concern yourself too much with the specifics and
worry more about how the observable behavior affects you. That is, if you
need multiple servers to be available on the same named pipe, then go
ahead and do that, and trust .NET to implement it in a reasonably
efficient way.
Whether .NET does or not, I can't say. But if you code to the API, then
if and when the API is improved (assuming it needs to be), your own code
will simply wind up taking advantage of that without additional effort on
your part.
I don't actually recall whether in the unmanaged named pipes API, i/o
completion ports are supported. Because they act in a fashion very
similar to file i/o, and because IOCP is supported for file i/o, I
_believe_ that IOCP is supported for named pipes as well. And given that
IOCP is used in other areas of .NET, it stands to reason that the .NET
implementation of named pipes would also use IOCP.
If all of that is true, then multiple servers would not actually map
one-to-one to extra threads. Rather, the IOCP thread pool would be used,
taking advantage of the efficiency gains IOCP offers.
If it's really important for you to know the exact details, you may have
to simply observe the behavior in the debugger, or look at the .NET source
code (either via Reflector or Microsoft's own source download service),
and see how it works.
Pete