KEMBAR78
Common Parameters should include a CancellationToken · Issue #19685 · PowerShell/PowerShell · GitHub
Skip to content

Common Parameters should include a CancellationToken #19685

@rhubarb-geek-nz

Description

@rhubarb-geek-nz

Summary of the new feature / enhancement

There have been a number of requests to add timeouts to various commands ( why always in seconds ? ) it would be simpler to add CancellationToken support to Common Parameters so that all commands automatically have the capability in a consistent manner.

While superficially a timeout might seem obvious and simple, a CancellationToken is far more useful and allows the client control over when the cancellation is requested, eg not just because of a timeout but because some other condition occurred after the command has been started.

Proposed technical implementation details (optional)

Proof of concept

This demonstrates a cancellation token working with Invoke-Command

Implementation - CommandWithCancellationToken.cs

Unit tests - CommandWithCancellationTokenTests.cs

Metadata

Metadata

Assignees

Labels

Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions