Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Blazor Multithreaded Javascript

I am trying to perform two tedious Javascript tasks in parallel with Blazor WebAssembly in .NET 6. My current code looks like this:

task1 = Task.Run(async () =>
{
  try
  {     
    await JSInProcessRuntime.InvokeAsync<int>("BuildTablesOne", new object[] {data1});
  }
  catch (Exception exc)
  {
    await JSInProcessRuntime.InvokeAsync<object>("console.log", exc.Message);
  }
});

task2 = Task.Run(async () =>
{
   try
   {     
      await JSInProcessRuntime.InvokeAsync<int>("BuildTablesTwo", new object[] {data2});
   }
   catch (Exception exc)
   {
      await JSInProcessRuntime.InvokeAsync<object>("console.log", exc.Message);
   }
});

await Task.WhenAll(task1, task2);

These tasks seemingly don't run in parallel as I'd like. I estimate that each of the tasks takes around 2 seconds to finish separately. Totaling 4 seconds of execution time running after each other. In my ideal scenario I would be able to run these both in parallel for a total execution time of 2 seconds. Now I learned that Javascript does not have support for Multithreading but then I also came across WebWorkers and similar concepts and was thinking that maybe Blazor WASM has mechanisms to hook into those new concepts and tools somehow.

Is the above what I am trying to do even achievable, and if yes what can I change in the code to make this fully run in parallel?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!