Skip to content

CancellationTokenExtensions.CombineWith() forgets the original token when combining 3 or more tokens #1442

Description

@DaRosenberg

Bug description

This method can be used to combine an arbitrary number of cancellation tokens:

public static CombinedCancellationToken CombineWith(this CancellationToken original, params CancellationToken[] others)

If more than 2 of the provided tokens (including the original one that the extension method was called on) can be cancelled, the method goes into the least optimized code path here:

This code path forgets about the "original" cancellation token, and only combines the "others". As a result, the resulting combined cancellation token does not react to cancellation of the "original" token.

Repro steps

Described above.

Expected behavior

The resulting combined cancellation token should include and reflect cancellations on the "original" token as well as any "others".

Actual behavior

Instead the resulting combined cancellation token ignores the "original" token and only reflects cancellation on the "others".

  • Version used: 17.11.20

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions