Open devlynx opened 8 years ago
Found a few similar libraries that already support that: https://github.com/jamesmanning/RunProcessAsTask https://github.com/madelson/MedallionShell
ConsoleAppLauncher differs by providing access to console output in real-time without waiting for the process to exit. Do you need async/await for such scenarios? What should be the result type of async method? Can you provide a signature for anticipated async method?
Thanks, Slava
I decided to use RunProcessAsTask. Thanks for pointing me in that direction.
Similar problems here: I need progressive results and the external C/C++ process doesn't seem to want to exit and return possibly because it is waiting on keyboard input from the console rather than stdin. I will look at CliWrap and MedallionShell first.. I have had this experience before where it works with cmd.exe but not directly with the process so it might be an undesirable alternative of writing the stdin to a random temp file first then use cmd.exe shell redirection then securely overwriting the temp file before deleting. Yucky but unavoidable but still doesn't solve progressive output returns which might have to be fixed by parsing the script I am passing in stdin to the external app and executing the above line by line or block by block to get feedback. Where there is a will there may be a way..
I got it working like a treat with CliWrap after an initial gotcha (.EnableExitCodeValidation(false).EnableStandardErrorValidation(false) required!) though I would have liked to have used Medallion instead as it turns out the CliWrap .SetStandardOutputCallback(stdoutCallback ?? UpdateDummy).SetStandardErrorCallback(stderrCallback ?? UpdateDummy) callbacks proved superior to get interactive real time output log window updates: ultimately I didn't need anything complex thread-wise but a single Task
Is it possible to support async/await so that the UI does not lock up during the running of the console app?
Thanks,
Mike