An example: if your code is like

1
2
3

varIsRunning.Value <- true
runComputation()
varIsRunning.Value <- false

rewrite it like this:

1
2
3
4
5

varIsRunning.Value <- true
async {
do! runComputation()
varIsRunning.Value <- false
} |> Async.Start

This will also need that your code inside runComputation is also wrapped in an async.

By on 2/2/2018 6:40 AM ()

Hi! Do you have your long computation as an async expression? (I am assuming you use F#. If you are interested in C#, please tell and I will give advice for that too.)

JavaScript is single-threaded, so WebSharper is using a round-robin scheduler for running asyncs, regularly yielding so that other JS event handlers can run too. Even if you have your outer computation function as async, if it is calling any function that takes long to execute (for example has large loops), that part will be blocking (preventing any UI updates, including WebSharper.UI reactive logic). So all potentionally long-running functions should be written as an async. Having loops inside an async expression, F# automatically breaks it down so it is yielding control after every iteration.

By on 2/2/2018 6:14 AM ()