how to wait on a cancellation token AND an EventWaitHandle at the same time, in F#?

171 views Asked by At

I would like to find a way to combine these two lines:

cancellationToken.WaitHandle.WaitOne() |> ignore
waitHandle.WaitOne() |> ignore

whichever happens first would let the execution flow continue. Can this be done?

1

There are 1 answers

0
Brian Berns On

I assume you could put the the two handles in an array and then wait on it. Something like:

[|
    cancellationToken.WaitHandle
    waitHandle
|] |> WaitHandle.WaitAny |> ignore

Note: I have not tried to compile or run this code.

Related Questions in F#