You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When code calls context.GetCancellationToken() to pass that token to a handler's logic and that logic (or other code outside caller's control) calls Environment.Exit(), the application deadlocks.
This is caused by CancelOnProcessTermination() subscribing to the CancellationHandlingAdded event.
Repro on version 2.0.0-beta4.22272.1:
usingSystem.CommandLine;varrootCommand=newRootCommand();vartestCommand=newCommand("test","Test command");testCommand.SetHandler(async context =>{awaitExitAsync(context.GetCancellationToken());});rootCommand.AddCommand(testCommand);awaitrootCommand.InvokeAsync(args);staticTaskExitAsync(CancellationTokencancellationToken){Console.WriteLine("Exiting...");// This hangsEnvironment.Exit(-1);// This is ignoredreturnTask.CompletedTask;}
If you comment out the Environment.Exit, the application exits successfully. When it's present, it indefinitely hangs there.
The text was updated successfully, but these errors were encountered:
staticasyncTaskMain(string[]args){varrootCommand=newRootCommand();vartestCommand=newCommand("test","Test command");testCommand.SetAction((context,cancellationToken)=>ExitAsync(cancellationToken));rootCommand.Subcommands.Add(testCommand);awaitrootCommand.Parse(args).InvokeAsync();staticTaskExitAsync(CancellationTokencancellationToken){Console.WriteLine("Exiting...");// This hangsEnvironment.Exit(-1);// This is ignoredreturnTask.CompletedTask;}}
In the next few weeks we are going to release a new nuget package to nuget.org.
When code calls
context.GetCancellationToken()
to pass that token to a handler's logic and that logic (or other code outside caller's control) callsEnvironment.Exit()
, the application deadlocks.This is caused by
CancelOnProcessTermination()
subscribing to theCancellationHandlingAdded
event.Repro on version 2.0.0-beta4.22272.1:
If you comment out the
Environment.Exit
, the application exits successfully. When it's present, it indefinitely hangs there.The text was updated successfully, but these errors were encountered: