Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda