In a C # application in the main thread, a process is created and started. However, the main thread freezes until the child process terminates. A child process can work for a long time and I would like to immediately return control to the main thread. Is this provided by means of the C # language?

PS: I found information that Event Handlers can be used, but they work to complete the process.

    1 answer 1

    Without additional gestures, the parent process never blocks or waits for a child.

    Find a line that blocks the parent process - and delete it :)

    UPD If you need to read the output of the child process, then in the simple case it is enough to postpone the launch and the reading by time. This method implies that data availability is known from an external source.

    Otherwise, you need to read in a separate thread.

    Well, or you can use asynchronous operations, as suggested by Grundy in the comments.

    • How can it look, for example? - neo
    • one
      @neo this line (surprise!) writes the entire output of the child process to the line. How do you imagine the continuation of the work of the parent process with the string variable unfilled to the end? :) - Pavel Mayorov
    • one
      @PavelMayorov, I suspect this was exactly the question :) - Grundy
    • one
      @neo updated the answer - Pavel Mayorov
    • one
      @neo It is necessary to process the output of the child process as it is received. - Pavel Mayorov