C# simultanous console input and output?

后端 未结 7 521
我寻月下人不归
我寻月下人不归 2021-01-02 16:36

I am writing a server app and I want it to be console based. I need the user to be able to input different commands, but at the same time there is a possibility that somethi

7条回答
  •  Happy的楠姐
    2021-01-02 17:19

    This sort of thing becomes a somewhat simpler problem if you treat the server as a client/server application. Let the server have "n" connections to client admin applications that send commands and receive output. The client application could completely separate input and output, having one thread to handle input, and one to handle output.

    The output thread could block if the input thread is in the middle of entering a line, and unblock when the line is either cancelled or committed.

提交回复
热议问题