-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run on same thread in generic host #195
Comments
Sure, I'd take a PR. @lucastheisen would this change be fine? |
No objection here. Honestly, I don't have any UI use cases, so have no idea what the implications would be there. I don't imagine it would hurt anything. |
It should work and would be better because async should be all the way from top to bottom and Task.FromResult is just like any other task (some results are internally cached), see first chapter in https://blogs.msdn.microsoft.com/dotnet/2018/11/07/understanding-the-whys-whats-and-whens-of-valuetask/ for better explanation. No need for my PR anymore. |
I was playing with new version and run into some trouble because my code wasn't executed on UI thread. It lead to code in https://github.com/natemcmaster/CommandLineUtils/blob/master/src/Hosting.CommandLine/Internal/CommandLineService.cs class and this method:
It uses
Task.Run
to execute application login on different thread which is not desired in certain scenarios where you want your code to execute on the UI thread.It can be easily rewritten to:
That way the application logic is always executed on same thread. Would you be interested in PR for this change?
The text was updated successfully, but these errors were encountered: