Can I explicitly check for cancellation/terminate async computation?

Ste*_*sen 6 f# asynchronous

I have an async computation like the following (see inline comments):

async {
  //...
  do! Async.Sleep(100) //cancellation may happen during sleep
  //... but isn't checked at the end of the sleep, so regular, non-async computations are executed here 
}
Run Code Online (Sandbox Code Playgroud)

In order to force a cancellation check/terminate the entire async computation before the "regular" computation part is reached, I insert an effective no-op do! Async.Sleep(1) immediately after the do! Async.Sleep(100). Is there a cleaner way to do this? Possibly even something like do! Async.Nop.

Jac*_* P. 5

这样的事情怎么样:

let nop = async.Return ()
Run Code Online (Sandbox Code Playgroud)

然后你可以使用它像:

async {
    // ...
    do! Async.Sleep 100
    do! nop
}
Run Code Online (Sandbox Code Playgroud)