© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
5 replies
JakeWindle

SignalR client method calling C#/JS interop, hangs indefinitely.

Hey all, I have a project that I've been working on that involves heavy usage of SignalR and C#/JS interop.

The basic flow goes like this:
1. On SignalR connect, send the client a message
GetDimensions
GetDimensions
that the client acts on.
2. When client receives
GetDimensions
GetDimensions
, call C# service class that imports JS module
3. C# service class calls JS function to grab screen dimensions, await result
4. Return result as
ValueTask<ScreenDimensions>
ValueTask<ScreenDimensions>
from service class.
5. Call the SignalR hub
SetScreenDimensions
SetScreenDimensions
method with the return from the service class.

My problem: This is working fine on Linux, but on Windows (using Edge and Chrome), the code I've noted with
// THIS HANGS HERE
// THIS HANGS HERE
won't run. I can see in teh JS console that I'm reaching that client method, but that call I'm awaiting hangs indefinitely.

Code samples:

Client Receive Method
    hubConnection.On("GetDimensions", async () =>
    {
        var dimensions = await _screenInfo.GetDimensions(); // THIS HANGS HERE, does JS stuff
        await hubConnection.SendAsync(
            "CalculateDisplayArea",
            dimensions.width,
            dimensions.height,
            0);
    });
    hubConnection.On("GetDimensions", async () =>
    {
        var dimensions = await _screenInfo.GetDimensions(); // THIS HANGS HERE, does JS stuff
        await hubConnection.SendAsync(
            "CalculateDisplayArea",
            dimensions.width,
            dimensions.height,
            0);
    });


ScreenInfo class method:
    public async ValueTask<ScreenDimensions> GetDimensions()
    {
        if (_screenDimensions is not null)
        {
            return _screenDimensions;
        }

        // Load the module if null.
        _module ??= await _js.InvokeAsync<IJSObjectReference>("import", _dbModulePath);

        _screenDimensions = await _module.InvokeAsync<ScreenDimensions>("getDimensions");
        return _screenDimensions;
    }
    public async ValueTask<ScreenDimensions> GetDimensions()
    {
        if (_screenDimensions is not null)
        {
            return _screenDimensions;
        }

        // Load the module if null.
        _module ??= await _js.InvokeAsync<IJSObjectReference>("import", _dbModulePath);

        _screenDimensions = await _module.InvokeAsync<ScreenDimensions>("getDimensions");
        return _screenDimensions;
    }


Anything glaringly wrong? I can't figure out why this call would work on Linux, but it would hang on Windows.

dotnet version: 7.0.402
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

SignalR Blocking Issue: Infinite Wait When Calling a Method from Client
C#CC# / help
2y ago
✅ Complicated error with C# SignalR client
C#CC# / help
3y ago
JsonSerializer.DeserializeAsync() randomly hangs indefinitely [Answered]
C#CC# / help
4y ago
❔ Need help with C#/C++ interop
C#CC# / help
3y ago