Skip to content

Commit 117c8e6

Browse files
committed
disposes the cancellation token source
Ensures the cancellation token source is properly disposed of after cancellation. Prevents potential resource leaks by explicitly disposing of the CancellationTokenSource after the Console.CancelKeyPress event is triggered.
1 parent eea5296 commit 117c8e6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

new-cli/GitVersion.Cli/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
};
1313

1414
var cts = new CancellationTokenSource();
15-
Console.CancelKeyPress += (_, _) => cts.Cancel();
15+
Console.CancelKeyPress += (_, _) =>
16+
{
17+
cts.Cancel();
18+
cts.Dispose();
19+
};
1620

1721
await using var serviceProvider = RegisterModules(modules);
1822
var app = serviceProvider.GetRequiredService<ICliApp>();

0 commit comments

Comments
 (0)