Skip to content

feat(Async): StartTaskImmediate - #1

Closed
bartelink wants to merge 7 commits into
async-awaitfrom
async-sti
Closed

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

Conversation

@bartelink

@bartelinkbartelink 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
CopilotAI review requested due to automatic review settings May 22, 2026 13:42

CopilotAI 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
FileDescription
tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fsAdds coverage for StartTaskImmediate across Task/ValueTask scenarios.
tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.release.bslRecords new public API entries for netstandard2.1 release surface-area validation.
tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.debug.bslRecords new public API entries for netstandard2.1 debug surface-area validation.
src/FSharp.Core/async.fsiDeclares the new StartTaskImmediate overloads with XML docs.
src/FSharp.Core/async.fsImplements StartTaskImmediate via Async.CancellationToken + Async.Await.
docs/release-notes/.FSharp.Core/11.0.100.mdNotes the new API addition in release notes.

Comment threadsrc/FSharp.Core/async.fsi
@bartelink
bartelinkforce-pushed the async-await branch 3 times, most recently from 430f0d8 to e1a34f0CompareMay 22, 2026 17:18
@bartelink
bartelinkforce-pushed the async-sti branch 2 times, most recently from 9a9977a to 8cd3e4eCompareMay 22, 2026 17:56
@bartelink
bartelinkforce-pushed the async-sti branch 4 times, most recently from ee01fe6 to 6db3977CompareMay 22, 2026 22:00
@bartelink
bartelinkforce-pushed the async-await branch 2 times, most recently from 93badc9 to 50814f5CompareMay 25, 2026 12:03
@bartelink
bartelinkforce-pushed the async-sti branch 3 times, most recently from 1ca22cf to 9becd19CompareMay 25, 2026 17:40
@bartelink
bartelinkforce-pushed the async-sti branch 2 times, most recently from 52f8576 to 87675b1CompareMay 25, 2026 17:50
AwaitUnitTask true (task.AsTask())
#endif

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

Copy link
Copy Markdown
OwnerAuthor

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?

CopilotAI 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 threadsrc/FSharp.Core/async.fsi Outdated
Comment threadsrc/FSharp.Core/async.fsi Outdated
Comment threaddocs/release-notes/.FSharp.Core/11.0.100.md Outdated
@bartelink

Copy link
Copy Markdown
OwnerAuthor

Closing; reposted as dotnet/fsharp PR 20258

Sign up for freeto 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

@bartelink