shut down program if client never makes connection RRS feed

  • Question

  • The example code from Microsoft shows pipeServer.WaitForConnection( ) which is blocking.

    If the client never connects, the program cannot be shut down.

    How do I use ASyncCallback function in conjunction with BeginWaitForConnection( ) ?

    Microsoft has no examples.

    Thursday, May 23, 2019 6:47 PM

All replies

  • If you don't mind looking at a C# article/code sample go here or here, else I have nothing. And please note I rarely suggest C# code in this forum but there are pretty much not many examples out there to begin with.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Thursday, May 23, 2019 7:03 PM
  • Thank you.

    So, short of creating a simple client program to connect to the server program, there is no way to shut the server program down once it has started short of going into Task Manager and ending the process?

    I am researching Named Pipes because I am looking for an way to exchange short packets of information (< 200 bytes) between two programs?

    Program #1  sends 5 bytes to Program #2

    Program #2 then responds with 127 bytes to Program #1

    and repeat until both programs are closed.


    Thursday, May 23, 2019 9:31 PM

  • How do I use ASyncCallback function in conjunction with BeginWaitForConnection( ) ?


    I found a link,it uses NamedPipeServerStream.BeginWaitForConnection(AsyncCallback, Object) Method,you can see it.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, May 27, 2019 3:02 AM