Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/FSharp.Control.TaskSeq/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module ValueTask =

/// Ignore a ValueTask<'T>, returns a non-generic ValueTask.
let inline ignore (vtask: ValueTask<'T>) =
if vtask.IsCompleted then
// this implementation follows Stephen Toub's advice, see:
// https://github.com/dotnet/runtime/issues/31503#issuecomment-554415966
if vtask.IsCompletedSuccessfully then
// ensure any side effect executes
vtask.Result |> ignore
ValueTask()
else
ValueTask(vtask.AsTask())
Expand Down Expand Up @@ -63,6 +67,7 @@ module Task =
/// Convert a Task<'T> into a non-generic Task, ignoring the result
let inline ignore (task: Task<'T>) =
TaskBuilder.task {
// ensure the task is awaited
let! _ = task
return ()
}
Expand Down