How to start a Process in a Thread

前端 未结 5 473
陌清茗
陌清茗 2021-01-02 08:45

FURTHER EDIT the following is not production code - I\'m just playing around with a couple of classes trying to figure out how I run processes wit

5条回答
  •  时光取名叫无心
    2021-01-02 09:18

    Not answering directly the OP, but as this thread helped me track the right direction, I do want to answer this:

    "starting it on a thread is completely pointless"

    I have a .Net server that uses NodeJS as its TCP socket manager. I wanted the NodeJS to write to the same output as the .Net server and they both run in parallel. So opening in a new thread allowed me to use

    processNodeJS.BeginErrorReadLine()
    processNodeJS.BeginOutputReadLine()
    processNodeJS.WaitForExit()
    

    while not blocking the main thread of the .Net server.

    I hope it makes sense to someone and if you have a better way to implement what I've just described, I'll be more than happy to hear.

提交回复
热议问题