Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4531

Web event handling in multiple windows (Blazor)

$
0
0

I'm just starting out on the web and this time I'm having trouble with event handling. I develop with blazor, but this seems like a universally applicable problem.

Where I'm stuck is this. I want to notify the page when I get a message. I had no problem with this when I had one browser screen, but when I test my web with two screens open, the events don't work properly. how do I fix this?

Below is my code.

ServiceInfoReceiveHandler.cspublic event EventHandler<(string contentType, string serverName, string message)> InstallServiceInfoReceived;...public void Receive(BasicDeliverEventArgs eventArgs){  if (contentType == "SVCMGMT/INSTALL/SVCINFO")  {    InstallServiceInfoReceived?.Invoke(this, (contentType, serverName, message));    ...  }}

I fire the event like this and the receive function is always called whenever a message comes in. It's not a matter of the message not arriving.

page.razor@inject ServiceInfoReceiveHandler _serviceInfoReceiveHandlerprotected override async Task OnInitializedAsync(){   _serviceInfoReceiveHandler.InstallServiceInfoReceived += OnServiceInfoReceived;}private async void OnServiceInfoReceived(object sender, (string contentType, string serverName, string message) e){...}

The razor page I want the result of is like above, but OnInfoReceived is not called.


Viewing all articles
Browse latest Browse all 4531


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>