C#中有什么东西像java中的aio吗? [英] Is there something in C# which is like aio in java?

查看:167
本文介绍了C#中有什么东西像java中的aio吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在java中,有AsynchronousSocketChannel类。我们可以用它来接受一个没有阻塞的套接字。我知道有一个名为Socket.BeginConnect的方法。但我不知道它是否是一种非阻塞方法。或者它只是另一个线程中的阻塞方法。

In java, there is "AsynchronousSocketChannel" class. We can use it to accept a socket which is not blocking. I know there is a method named "Socket.BeginConnect". But I don't know if it is a non-blocking method. Or it is just a blocking method in another thread.

推荐答案

文档Socket.BeginConnect方法(EndPoint,AsyncCallback,Object)(System.Net.Sockets) [ ^ ]说:

The documentation Socket.BeginConnect Method (EndPoint, AsyncCallback, Object) (System.Net.Sockets)[^] says:
When your application calls BeginConnect, the system will use a separate thread to execute the specified callback method, and will block on EndConnect until the Socket connects successfully or throws an exception.



这意味着它可以像我期望的那样工作:它启动一个单独的线程来执行阻塞操作。


Which means it works as I would expect: it starts a separate thread to perform the blocking operation.


这篇关于C#中有什么东西像java中的aio吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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