.NET如何使用IO线程或IO完成端口? [英] How does .NET make use of IO Threads or IO Completion Ports?

查看:150
本文介绍了.NET如何使用IO线程或IO完成端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个.NET应用程序,它对多种Web服务进行多个并发调用,收集其响应,然后对这些响应进行一些计算。在试图获得额外的性能,我一直在调查使用通过使用IO完成端口使用.NET的IO线程的方法。我已经阅读了几个资源,包括Joe Duffy的最近的书Concurrent Programming on 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完成端口的基本前提是当等待I / O操作时,有一个线程池等待I / O操作完成(假设您注册使用I / 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 Machine):

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

这篇关于.NET如何使用IO线程或IO完成端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆