slavagu / ConsoleAppLauncher

Console application wrapper in .NET C# that captures all the output generated in the console
MIT License
56 stars 15 forks source link

Support async/await #2

Open devlynx opened 8 years ago

devlynx commented 8 years ago

Is it possible to support async/await so that the UI does not lock up during the running of the console app?

Thanks,

Mike

slavagu commented 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

devlynx commented 8 years ago

I decided to use RunProcessAsTask. Thanks for pointing me in that direction.

matthewsheeran commented 6 years ago

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..

matthewsheeran commented 6 years ago

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 with a few Dispatcher.BeginInvokes! I have only to add ProgressBar support into the existing Callbacks after counting how many code lines I have to execute in advance as my rough but good enough gauge!! Wunderbar!!!