Closed doddi321 closed 5 months ago
I expect that will be OK.
If the application had set up a SynchronizationContext before rootCommand.InvokeAsync, then that could cause problems with ASP.NET Core; but your code doesn't do that.
You could also get a CancellationToken from System.CommandLine and gracefully shut down the host when cancellation is requested. This seems to have a risk of deadlock on .NET Framework (https://github.com/dotnet/command-line-api/issues/832), but modern versions of ASP.NET Core aren't supported on .NET Framework anyway.
It will add a bit to your callstack. That isn't a problem, but you'll see it.
You could also set a flag you evaluate after parsing. We do that in some of the tests. While I do not think what you are doing is likely to have problems, it would pull the significant code you have in the handler in a place in your code you could might be able to manage it better, from a human standpoint, and possibly test it better,
@KalleOlaviNiemitalo @KathleenDollard Thanks for the feedback and observations!
Hi, I have a service that I want to function as an Api and run some other processes like this:
Will running an Api inside a handler cause some unexpected problems?