WASM Multithreading
#19035
Replies: 1 comment 2 replies
-
Thanks for the question. Wasm threading is experimental overall, is a best effort support in .NET 8, and is not supported in .NET 9 on Uno's side because of structural changes made by the runtime. We expect this to change in .NET 10, however. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For several years, I've been writing a .NET Standard 2.0 library (using PolySharp for newer C# language features) that does some graphics processing on the CPU, which means many operations it does are CPU-bound. When it came time to add multi-threading, I went through the codebase and just replaced a lot of
Select
queries with this:Just replacing
Select
withParallelize
made the same operations take a small fraction of the time they used to. It works great whenever you have a series of CPU-bound tasks that you know in advance don't depend on each other or on anything that changes to get done.Now I'd like to give my library a web front-end for people to use and host the web front-end for free on Github Pages. So naturally, the first tool I reached for was Blazor WASM because that would be the Microsoft way to do this. The Parallelize method I wrote works on Blazor WASM, except single-threaded because Blazor WASM only provides a single-threaded runtime. Being single-threaded means it blocks the UI which is bad ... but the user's patience is eventually rewarded with the result they requested so that's good.
But then I read that Uno Platform has multi-threading support on WASM but I'm not sure I fully understand the requirements. Would a PLINQ method like this be able to actually use multi-threading? Apparently it requires a special header to be added to the site: so is this something I could still host for free on Github Pages? When making multi-threaded code, what stuff is allowed vs not allowed on WASM?
The real point / heart of my question is that I am considering whether I should port my front-end from Blazor WASM to Uno or just start over coding the front-end in Uno solely in order to get the multi-threading feature. Is that worth it? I'd hate to invest many hours in learning the Uno platform just for this only to realize that multi-threading for my application would be untenable.
Beta Was this translation helpful? Give feedback.
All reactions