File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
src/FSharp.Control.TaskSeq Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,11 @@ module ValueTask =
3333
3434 /// Ignore a ValueTask<'T>, returns a non-generic ValueTask.
3535 let inline ignore ( vtask : ValueTask < 'T >) =
36- if vtask.IsCompleted then
36+ // this implementation follows Stephen Toub's advice, see:
37+ // https://github.com/dotnet/runtime/issues/31503#issuecomment-554415966
38+ if vtask.IsCompletedSuccessfully then
39+ // ensure any side effect executes
40+ vtask.Result |> ignore
3741 ValueTask()
3842 else
3943 ValueTask( vtask.AsTask())
@@ -63,6 +67,7 @@ module Task =
6367 /// Convert a Task<'T> into a non-generic Task, ignoring the result
6468 let inline ignore ( task : Task < 'T >) =
6569 TaskBuilder.task {
70+ // ensure the task is awaited
6671 let! _ = task
6772 return ()
6873 }
You can’t perform that action at this time.
0 commit comments