C
C#13mo ago
SCP999

❔ Blazor - Event executed more than once

It’s the first time I’m asking something on the net, so sorry if the formatting or the way the answer is posed is wrong. I’m having a problem with an event inside a function. Here’s the code
[JSInvokableAttribute("inserisci")]
public async Task inserisci(float[] points)
{
await OnInserisci.InvokeAsync(points);
}
[JSInvokableAttribute("inserisci")]
public async Task inserisci(float[] points)
{
await OnInserisci.InvokeAsync(points);
}
This function starts after I pressed a point in a map, but what’s strange is that, after the first time I press, this function executes 2^n times (where n is the number of times I pressed on the map) adding more and more of the same element. To be specific, the debugger shows me that after the execution reaches the closing parenthesis it starts again from the starts even though there are no loops, recursions or calling from the JS script. Do you know why this happens? I’m not finding anything about it on the net. Thanks in advance for the help! (If you need the rest of the code let me know)
2 Replies
JakenVeina
JakenVeina13mo ago
you are leaking event subscriptions either an event handler that is calling inserisci(), or a hanlder for OnInserisci somehow, each event occurrance is triggering new subscription to the event
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts