dotnet / dotnet/command-line-api

Termination handling in .net framework 4.7.2 deadlocks always with Ctrl + C

Open
#1,450 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

[ConsoleApp1.zip](https://github.com/dotnet/command-line-api/files/7415957/ConsoleApp1.zip)

This program works in .net core and .net 5. Framework, however, never works when you cancel with Ctrl + C

This is the gist of the program:

```
static async Task Main(string[] args)
{
var thing = new Command("thing");
thing.Handler = CommandHandler.Create(async (CancellationToken token) =>
{
await Task.Delay(TimeSpan.FromSeconds(10), token);
});

var root = new RootCommand
{
thing
};

return await root.InvokeAsync(args);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.