Skip to content

feat(Async): StartTaskImmediate#1

Open
bartelink wants to merge 4 commits into
async-awaitfrom
async-sti
Open

feat(Async): StartTaskImmediate#1
bartelink wants to merge 4 commits into
async-awaitfrom
async-sti

Conversation

@bartelink

@bartelink bartelink commented May 22, 2026

Copy link
Copy Markdown
Owner

Addresses the task start+await aspect of fsharp/fslang-suggestions#1284

See also fsharp/fslang-suggestions#1467

  • Update Await/AwaitTask to mention that this is how you tie in cancellation

@bartelink bartelink marked this pull request as ready for review May 22, 2026 13:42
Copilot AI review requested due to automatic review settings May 22, 2026 13:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Microsoft.FSharp.Control.Async in FSharp.Core with Async.StartTaskImmediate, a helper that captures the ambient CancellationToken, passes it to a task/value-task factory, and awaits the result using the newer Async.Await semantics (notably exception unwrapping).

Changes:

  • Add Async.StartTaskImmediate overloads for Task, Task<'T>, and (on NETSTANDARD2_1) ValueTask, ValueTask<'T>.
  • Add unit tests covering result flow, cancellation token flow, exception unwrapping, and cancellation behavior.
  • Update FSharp.Core surface area baselines (netstandard2.1) and add a release-notes entry.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs Adds coverage for StartTaskImmediate across Task/ValueTask scenarios.
tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.release.bsl Records new public API entries for netstandard2.1 release surface-area validation.
tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.debug.bsl Records new public API entries for netstandard2.1 debug surface-area validation.
src/FSharp.Core/async.fsi Declares the new StartTaskImmediate overloads with XML docs.
src/FSharp.Core/async.fs Implements StartTaskImmediate via Async.CancellationToken + Async.Await.
docs/release-notes/.FSharp.Core/11.0.100.md Notes the new API addition in release notes.

Comment thread tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs Outdated
Comment thread src/FSharp.Core/async.fsi
@bartelink bartelink force-pushed the async-await branch 3 times, most recently from 430f0d8 to e1a34f0 Compare May 22, 2026 17:18
@bartelink bartelink force-pushed the async-sti branch 2 times, most recently from 9a9977a to 8cd3e4e Compare May 22, 2026 17:56
@bartelink bartelink force-pushed the async-sti branch 4 times, most recently from ee01fe6 to 6db3977 Compare May 22, 2026 22:00
@bartelink bartelink force-pushed the async-await branch 2 times, most recently from 93badc9 to 50814f5 Compare May 25, 2026 12:03
@bartelink bartelink force-pushed the async-sti branch 3 times, most recently from 1ca22cf to 9becd19 Compare May 25, 2026 17:40
@bartelink bartelink force-pushed the async-sti branch 2 times, most recently from 52f8576 to 87675b1 Compare May 25, 2026 17:50
Comment thread src/FSharp.Core/async.fs
AwaitUnitTask true (task.AsTask())
#endif

static member StartTaskImmediate(createTask: CancellationToken -> Task<'T>) : Async<'T> =

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is startTask a better parameter name?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread src/FSharp.Core/async.fsi Outdated
Comment thread src/FSharp.Core/async.fsi Outdated
Comment thread docs/release-notes/.FSharp.Core/11.0.100.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants