Is there a general way to gain external control over the execution of an arbitrary asynchronous workflow, for suspension and resumption? Akin to a CancellationToken but more like a SuspendResumeToken where one could simply do things like:
let suspendResumeToken = new SuspendResumeToken()
Async.Start(longRunningAsync, suspendResumeToken=suspendResumeToken)
...
// meanwhile
async {
do! suspendResumeToken.SuspendAsync()
printfn "Suspended longRunningAsync!"
do! suspendResumeToken.ResumeAsync()
printfn "Resumed longRunningAsync!"
}
I could emulate the behavior for recursive or iterated functions, by checking such a token at every iteration or recursion step, but since async workflows have natural yield points, it would be natural to have that built-in, as a general way to control async scheduling.