Skip to content

Update docs: how to handle process cancellation #2684

@DanielTuran

Description

@DanielTuran

In 2.0.0-rc.1.25451.107 CancellationTokens are not working by default.

RootCommand rootCommand = new();
rootCommand.SetAction(async (parseResult, cancellationToken) => {
	cancellationToken.Register(() => Console.WriteLine("Cancellation requested"));
	await Task.Delay(10000, cancellationToken);
	return 0;
});
await rootCommand.Parse(args).InvokeAsync();

Please write docs on how properly handle process cancellation to gracefully exit the app.

Here are some scenarios where we might want to gracefully exit app:

  • user invoked CLI -> user pressed Ctrl+C
  • kubernetes job -> job cancelling by k8s controller
  • windows service -> service stopping

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions