TaskGroup Type
Structured concurrency: run multiple tasks, cancel all on first failure.
Similar to Go's errgroup.
Example
use group = new TaskGroup()
let mutable user = Unchecked.defaultof<_>
let mutable orders = Unchecked.defaultof<_>
group.Run(fun ct -> task { let! u = fetchUser ct in user <- u })
group.Run(fun ct -> task { let! o = fetchOrders ct in orders <- o })
do! group.WaitAll()
Constructors
| Constructor |
Description
|
|
Creates a TaskGroup linked to a parent CancellationToken. Parent token — group cancels when parent does.
|
|
Creates a TaskGroup with its own CancellationTokenSource.
|
Instance members
| Instance member |
Description
|
Full Usage:
this.Run
Parameters:
CancellationToken -> Task
-
Async function receiving the group's CancellationToken.
|
Add a task to the group. On failure, all other tasks are cancelled.
|
|
Token that is cancelled when any task fails or the group is disposed.
|
|
Wait for all tasks to complete. Throws AggregateException if any failed.
|
TDesu.FSharp