C# Remove Event Handler after is called or call it just once

c#, events

Solution

Create a method

public void Browser_LoadEnd(object sender, EventArgs e)
{
    BeginInvoke(new Action(() =>
    {
         MyCefStringVisitor visitor = new MyCefStringVisitor(this, m_url);
         _cefGlueBrowser.Browser.GetMainFrame().GetSource(visitor);
         loaded = true;
    }));
}

subscribe

_cefGlueBrowser.LoadEnd += Browser_LoadEnd;

and unsubscribe

_cefGlueBrowser.LoadEnd -= Browser_LoadEnd;

Note, I assume that the `LoadEnd` event takes `EventArgs` and not some derived class.

Problem

``` _cefGlueBrowser.LoadEnd += (s, e) => { BeginInvoke(new Action(() => { MyCefStringVisitor visitor = new MyCefStringVisitor(this, m_url); e.Browser.GetMainFrame().GetSource(visitor); loaded = true; })); }; ``` But problem is that Event Handler is called many times. After each JS reload for example. How to remove multiple calls. How to call `LoadEnd` event just once. I try with ``` _cefGlueBrowser.LoadEnd -= delegate { }; ``` but not working. What can i do? I want to call it just once!

Original source