超时或终止服务器NamedPipe中的WaitForConnection - .Net 3.5 [英] Timeout or terminate WaitForConnection in a server NamedPipe - .Net 3.5

查看:61
本文介绍了超时或终止服务器NamedPipe中的WaitForConnection - .Net 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.Net 3.5我在应用服务器和各种客户端(在其他机器上)之间的通信 通过命名管道通常没问题,但是如果客户端(正在监听命名管道的小应用程序)未启动并运行,该怎么办?服务器上的应用程序
有很多责任,让它永远等待通过管道向特定客户端发送信息是不可接受的。

.Net 3.5 My communication between the application server and various clients (on other machines)  via Named Pipes is generally okay, but what if the client (the small app that is listening on the named pipe) is not up and running? The application on the server has many responsibilities and having it wait forever to send info via the pipe to a particular client is not acceptible.

NamedPipeServerStream

NamedPipeServerStream

pipeIO =
NamedPipeServerStream (pipeName,
PipeDirection 。InOut);
pipeIO.WaitForConnection();

pipeIO = new NamedPipeServerStream(pipeName, PipeDirection.InOut); pipeIO.WaitForConnection();

有没有办法让WaitForConnection超时或终止,以便应用程序继续运行,
为客户端做其他事情?

Is there a way to make the WaitForConnection timeout or terminate so the application can go on and do other things for the client?

谢谢,

Thanks,

推荐答案

WaitForConnection方法可以采用表示超时的int参数。在建立连接之前超时到期后,该方法将抛出异常。

您也可以调用Begin WaitForConnection来异步等待连接。如果您以后关闭管道,
等待将被中止。

You may also call BeginWaitForConnection to wait for the connection asynchronously. If you later Close the pipe, the waiting will be aborted.


这篇关于超时或终止服务器NamedPipe中的WaitForConnection - .Net 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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