Header menu logo TDesu.FSharp

CancellationToken Module

CancellationToken helpers — reduces boilerplate for timeout + linked patterns.

Functions and values

Function or value Description

CancellationToken.linked timeout parent

Full Usage: CancellationToken.linked timeout parent

Parameters:
    timeout : TimeSpan - The duration after which cancellation is requested.
    parent : CancellationToken - The parent token to link with the timeout.

Returns: CancellationTokenSource * IDisposable A tuple of the linked CTS and a disposable that cleans up both.

Creates a linked CTS: cancels when parent is canceled OR after timeout. Disposes both internal CTS on dispose. Use with use.

timeout : TimeSpan

The duration after which cancellation is requested.

parent : CancellationToken

The parent token to link with the timeout.

Returns: CancellationTokenSource * IDisposable

A tuple of the linked CTS and a disposable that cleans up both.

CancellationToken.linkedFrom parent

Full Usage: CancellationToken.linkedFrom parent

Parameters:
Returns: CancellationTokenSource
Modifiers: inline

Creates a linked CTS from a parent token (no timeout). The parent token to link from.

parent : CancellationToken
Returns: CancellationTokenSource

CancellationToken.withTimeout timeout

Full Usage: CancellationToken.withTimeout timeout

Parameters:
Returns: CancellationTokenSource
Modifiers: inline

Creates a CTS that cancels after the given timeout. Use with use. The duration after which cancellation is requested.

timeout : TimeSpan
Returns: CancellationTokenSource

Type something to start searching.