Bolero icon indicating copy to clipboard operation
Bolero copied to clipboard

RunSynchronously hangs

Open amieres opened this issue 6 years ago • 5 comments

Running this code makes it hang upon return:

JSRuntime.Current.InvokeAsync( "alert", "Hello!") |> Async.AwaitTask |> Async.RunSynchronously

But this works ok:

JSRuntime.Current.InvokeAsync( "alert", "Hello!") |> Async.AwaitTask |> Async.Start

amieres avatar Dec 27 '18 10:12 amieres

Async.RunSynchronously doesn't make sense in JS runtimes as it will block the only thread that is running (js is single-threaded)

Zaid-Ajaj avatar Dec 27 '18 12:12 Zaid-Ajaj

Maybe, but it should not hang anyway. It should handle it more gracefully specially considering that the code is not targeted for JavaScript but for regular .Net.

amieres avatar Dec 27 '18 13:12 amieres

Looks like tasks also hang if you try to await them

Liminiens avatar Dec 29 '18 21:12 Liminiens

It depends on the task. Something that depends on user input will definitely hang, because we're running on the UI thread.

Unfortunately this is dependent on upstream changes. Threads need to be implemented in WebAssembly (they're currently experimental in Chrome) and then used by mono-wasm before we can have proper multithreading.

Tarmil avatar Dec 30 '18 09:12 Tarmil

Oh I should clarify. It hangs after responding to the alert message, after closing the dialog. It remains in a loop somewhere in the Wasm code.

amieres avatar Dec 30 '18 09:12 amieres

Closing as stale.

Tarmil avatar Aug 22 '23 13:08 Tarmil