我需要帮助我正在制作的应用程序.这是一个响应命令行参数的简单程序.如果第一次调用该应用程序,它将在另一个专用于它的线程上作为管道服务器(阻塞,非重叠)启动,而主线程执行其他操作.现在,用户仍然可以使用相同的应用程序可执行文件和命令行参数调用应用程序,但由于它不是应用程序的第一个实例,因此它使用管道将命令行参数传递给第一个实例,然后杀死自身.所以,它就像一个模式术语中的单例过程.
理想情况下,应该是这样的:
app.exe "first" // starts app.exe as a pipe server and prints "first"
app.exe "second" // client process causes server instance to print "second"
app.exe "third" // client process causes server instance to print "third"
app.exe "fourth" // client process causes server instance to print "fourth"
app.exe "fifth" // client process causes server instance to print "fifth"
app.exe -quit // client process causes server instance to terminate.
Run Code Online (Sandbox Code Playgroud)
现在,我唯一的问题是,当我执行上述操作时会发生这种情况:
app.exe "first" // starts app.exe as a pipe server and prints …Run Code Online (Sandbox Code Playgroud) named-pipes ×1