aspnetcore: [Server side] Doing a blocking call on IJSRuntime.InvokeAsync ends up locking the server

Super nitpicky, but doing a .Result or 'Wait on the task returned by IJSRuntime locks up the server. E.g.

void DoLog()
{
    JSRuntime.Current.InvokeAsync<string>("console.log", "Hello world").Wait();
}

The server does not respond to any further actions.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 22 (13 by maintainers)

Most upvoted comments

Hi, try to use it string tnkn=(JSRuntime.Current as IJSInprocess.Runtime).Invoke<string>(“GetTkn”,…) I used it and it worked for me in synchronous code. but this is not my personal hack. I saw this in some of the Blazors extensions unfortunately I don’t remember in which

@rynowak why not detect and throw, why “fix” it?