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

How to dispose delegate in blazor or c#

$
0
0

Below I have attached my blazor code.

private delegate Task keyActionDelegate(KeyboardEventArgs e);private KeyActionDelegate _keyActionDelegate;protected override async Task OnParametersSetAsync(){    await base.OnParametersSetAsync();    _keyActionDelegate = new KeyActionDelegate(keyActionHandler);    Attributes = BaseUtils.UpdateDictionary("onkeydown", _keyActionDelegate, Attributes);}internal async override void ComponentDispose(){    base.ComponentDispose();    _keyActionDelegate = null;}

A memory leak has occurred due to keyActionDelegate.

I have tried setting the null value to the _keyActionDelegate variable in the ComponentDispose() method, but still a memory leak has occurred. Is there any other way to avoid memory leaks?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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