简体   繁体   English

Java 中的 SelectionKey、SelectableChannel 和 Selector 的 C# 类?

[英]C# classes for SelectionKey, SelectableChannel and Selector in Java?

What are C# classes for SelectionKey, SelectableChannel and Selector in Java? Java 中的 SelectionKey、SelectableChannel 和 Selector 的 C# 类是什么? Are there any direct translations of those classes or what are the next best things?是否有这些课程的直接翻译或下一个最好的东西是什么?

Edit: As Marc Gravell pointed out, it's for a multiplexer for IO operations (network).编辑:正如 Marc Gravell 指出的,它是用于 IO 操作(网络)的多路复用器。

There aren't any classes directly corresponding to the java.nio model in .NET. .NET 中没有任何类直接对应于 java.nio model。 Asynchronous IO is typically performed using a BeginRead / EndRead (etc) approach.异步 IO 通常使用BeginRead / EndRead (等)方法执行。 There's also the event-based asynchonous model used by classes like WebClient .还有WebClient等类使用的基于事件的异步 model 。 Additionally in .NET 4 with the Task Parallel Library you can use task-based asynchrony, which can also take advantage of the Begin / End pattern.此外,在带有任务并行库的 .NET 4 中,您可以使用基于任务的异步,这也可以利用Begin / End模式。

You can read more about asynchronous IO in .NET in MSDN .您可以在 MSDN的 .NET 中阅读有关异步 IO 的更多信息。

Note that C# 5 will introduce asynchronous methods, which will make a lot of this easier.请注意,C# 5 将引入异步方法,这将使这一切变得更容易。

Take a look at this article which shows an example of what I think you are trying to achieve in C#.看看这篇文章,它展示了我认为你在 C# 中尝试实现的示例。 It shows how to use Socket.Select to achieve Multiplexed I/O它展示了如何使用Socket.Select来实现复用 I/O

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM