如何.NET使用IO线程或IO完成端口的?线程、端口、NET、IO

2023-09-02 10:36:14 作者:蜡笔小心

我们有一个.NET应用程序,使多个并发调用各种Web服务,收集他们的反应,然后做了一些计算过这些答复。在试图获得额外的性能,我一直在研究使用的方法是通过使用IO完成端口使用.NET的IO线程。我已经经历了很多资源,包括Windows上的乔·达菲最近的一本书并发编程,虽然我获取它们的用处,我有点不清楚,在.NET下他们的行为,并正在寻找一个简要说明阅读。

We have a .NET application that makes several concurrent calls to various web services, collects their responses and then makes a few calculations off those responses. In attempting to derive additional performance, I've been investigating the use of approaches that make use of .NET's IO threading via the use of IO completion ports. I've read through several resources including Joe Duffy's recent book Concurrent Programming on Windows and while I "get" their usefulness, I'm a little unclear as to their behavior within .NET and am looking for a concise explanation.

推荐答案

有机会,你没有,如果你已经在使用异步方法做任何事情。根据您所使用的调用Web服务的技术,最终,它会下降到在Win32 API拨打电话,从网络上获取字节,并为此目的,它将使用I / O完成端口为了处理异步调用。

Chances are that you don't have to do anything if you are using the asynchronous methods already. Depending on the technology that you are using for the call to the web service, ultimately, it's going to drop down to the Win32 API to make the call to get bytes from the network, and to that end, it will use I/O Completion Ports in order to handle asynchronous calls.

背后的I / O完成端口的基本premise是,在I / O操作等待的时候,还有一个就是一直在等待时,I / O操作完成后(假设你注册使用我一个线程池/ O完成端口)。当你的注册操作完成后,从I / O完成端口线程池中的线程来处理回调。

The basic premise behind I/O completion ports is that when waiting on I/O operations, there is a thread pool that is kept waiting for when the I/O operations complete (assuming you registered to use I/O completion ports). When your registered operation completes, the thread from the I/O completion port thread pool is used to handle the callback.

当然,呼唤的I / O完成端口后,你的线程可以继续做更多的工作,或终止时,选择权在你。

Of course, after calling out to the I/O completion port, your thread can move on to do more work, or terminate, the choice is up to you.

以下应有助于描述它更多:

The following should help describe it more:

I / O完成端口:

I/O Completion Ports:

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

在I / O完成端口(Wayback机器):

Inside I/O Completion Ports (WayBack Machine):

https://web.archive.org/web/20101101112358/http://doc.sch130.nsc.ru/www.sysinternals.com/ntw2k/info/comport.shtml