try
try copied to clipboard
Feature Request: Async support in Wasm dynamically compiled assemblies
Description
When compiling / loading a program if it contains some await / async Task.Result / Task.Wait it will end up in a deadlock.
More complex scenarios need to run the code in the browser using wasm (together with compilation, but that is easily achieved already)
Reproduce the issue
On the editor here: https://dotnet.microsoft.com/platform/try-dotnet Type:
System.Threading.Tasks.Task.Delay(100).Wait();
Investigation / Experiments:
This is not specific to the WasmCodeRunner, you can also see the behaviour here: https://github.com/Suchiman/Runny, which is a simplified version of the WasmCodeRunner, loads the assembly and Invokes the assembly EntryPoint.
Other experiments, like loading on the current AppDomain do not help (trying to get the same scheduler) or alternatives like CsharpScripting (which does not resolve the assemblies for compilation in Wasm).
This fixed in Suchiman Runny as follows: https://github.com/Suchiman/Runny/commit/6f4217804a2cac74d771f289bd113ccf41d597a8