Give your instance of the anonymous delegate a name:
EventHandler<NewEventArg> handler = delegate(object sender, NewEventArgs e)
{
//some code
};
Subject.NewEvent += handler;
Subject.NewEvent -= handler;
More Related Contents:
- delegate keyword vs. lambda notation
- Assigning events in object initializer
- Are C# events synchronous?
- How to correctly unregister an event handler
- How can I clear event subscriptions in C#?
- Pass Method as Parameter using C#
- Understanding events and event handlers in C#
- Should I avoid ‘async void’ event handlers?
- When & why to use delegates? [duplicate]
- BackgroundWorker RunWorkerCompleted Event
- Passing variable between winforms
- Super-simple example of C# observer/observable with delegates
- Performance of calling delegates vs methods
- How do C# Events work behind the scenes?
- Weak event handler model for use with lambdas
- How do I execute code AFTER a form has loaded?
- A reusable pattern to convert event into task
- Single click edit in WPF DataGrid
- How to pass an event to a method?
- Event Signature in .NET — Using a Strong Typed ‘Sender’? [closed]
- How would it be possible to remove all event handlers of the ‘Click’ event of a ‘Button’?
- MethodInvoker vs Action for Control.BeginInvoke
- How is this possible: OnPaint processed while in WaitOne
- What are the advantages of delegates? [duplicate]
- C#: Triggering an Event when an object is added to a Queue
- Events – naming convention and style
- Discrete Anonymous methods sharing a class?
- How do I unsubscribe all handlers from an event for a particular class in C#?
- Fire Form KeyPress event
- Passing a variable between Windows Forms forms