问题描述
.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 = newNamedPipeServerStream(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,
推荐答案
您也可以调用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!