Skip to content

Modifying the application Store from the background #73

@gtejeda

Description

@gtejeda

Greetings, I'm trying to modify my application store class starting from a PeriodicTimer in Blazor, then I call a service which makes the httpcalls and updates the store class (both the Synchronize method and the AppStore method that receives the new value in the state class are marked with the Action), however, the UI is not being updated.

My blazor component has the Observer attribute in place

[Action]
    async Task HandleTimerAsync(PeriodicTimer timer, CancellationToken cancel = default)
    {
        try
        {
            while (await timer.WaitForNextTickAsync(cancel))
            {
                await synchronizer. Synchronize();
                await InvokeAsync(() => StateHasChanged());
            }
        }
        catch (Exception)
        {
            //Handle the exception but don't propagate it
        }
    }

Has anybody done something like this on a backgroundservice or timer?
Thanks in advance,
Geo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions