超时或终止服务器NamedPipe中的WaitForConnection

编程入门 行业动态 更新时间:2024-10-24 18:23:06
本文介绍了超时或终止服务器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

本文发布于:2023-11-12 01:43:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580155.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   NamedPipe   WaitForConnection

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!