Open Closed

Background Task to Page comms with / without sockets / signal r #1241


User avatar
0
nowayja created

ABP 4.3.0 Blazor

In other Blazor server projects I have used the following technique to communicate between background servces and the pages

https://dzone.com/articles/blazor-how-tos-status-from-a-background-task

An alternate to this would be sockets but I would prefer to use

@code{
    protected override void OnInitialized()
    {
        State.OnChangeAsync += Refresh;
    }
    private async Task Refresh()
    {
        await InvokeAsync(StateHasChanged);
    }
    public void Dispose()
    {
        State.OnChangeAsync -= Refresh;
    }
}

Do you know iif this approach will work with Blazor WASM or should I fallback to traditional SignalR sockets

Many thanks in advance

J

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    @nowayja for my late response, @mladen will that work?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mladen.macanovic created

    The way of how you re-render component with StateHasChanged is the same with both Blazor WASM and Blazor Server projects. There is no diference there. But, since you mention SignalR, that is only possible with Blazor Server by default.

    If you want to have SIgnalR for Blazor WASM you will need to implement it in your project. Here is one way on how to implement it https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr-blazor?view=aspnetcore-5.0&tabs=visual-studio&pivots=webassembly

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 09, 2026, 11:56
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.