I'm writing C# code that runs Git commands via ProcessStartInfo.
I am aware in terms of syntax that I can run commands from the console in parallel by adding a single &
character between them. For example:
echo "Hello world!" & echo "Goodbye world!"
Because these commands run in parallel they're asynchronous, meaning their output order is random. The issue is that in my C# code I need to use the response from each command, and unfortunately there is no indicative output to tell me which output belongs to which command I ran.
Is there a way to tell which output came from which command?
For example, a way to echo specific text when the specific command has finished?
CodePudding user response:
echo "Hello world!" >1st.out 2>1st.err &
echo "Goodbye world!" >2nd.out 2>2nd.err &
CodePudding user response:
Just as you can open multiple command windows as a user and type commands in them, you can run multiple commandline programs as separate processes from C# in parallel and so read their output separately.