Wrap message processing logic in InvokeAsync calls

This commit is contained in:
Thorsten Sommer 2025-06-02 19:11:47 +02:00
parent ea41e84cf3
commit bc80f93047
No known key found for this signature in database
GPG Key ID: B0B7E2FC074BF1F5
2 changed files with 98 additions and 92 deletions

View File

@ -44,6 +44,8 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus
#region Implementation of IMessageBusReceiver
public async Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
await this.InvokeAsync(async () =>
{
switch (triggeredEvent)
{
@ -58,6 +60,7 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus
}
await this.ProcessIncomingMessage(sendingComponent, triggeredEvent, data);
});
}
public async Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)

View File

@ -138,6 +138,8 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
public string ComponentName => nameof(MainLayout);
public async Task ProcessMessage<TMessage>(ComponentBase? sendingComponent, Event triggeredEvent, TMessage? data)
{
await this.InvokeAsync(async () =>
{
switch (triggeredEvent)
{
@ -230,6 +232,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
await this.InvokeAsync(this.StateHasChanged);
break;
}
});
}
public Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)