Click here to Skip to main content
13,142,182 members (53,225 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

10.9K views
1 bookmarked
Posted 14 Sep 2011

The simplest trick to remove an event handler

, 15 Sep 2011
Rate this:
Please Sign up or sign in to vote.
Trick to remove an event handler out of the scope of the handler
WorkStarted is an event (with existing handler):

this.WorkStarted -= this.WorkStarted;


The handler method could be out of the scope (as parameter in another method for instance). It works only in the class that defines the event (added by Andrew Rissing).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

A.J.Wegierski
Web Developer
Poland Poland
Complicated

You may also be interested in...

Pro

Comments and Discussions

 
Generalnice .. Pin
dineshkummarc17-Nov-11 23:38
memberdineshkummarc17-Nov-11 23:38 
GeneralThis only works though from within the class that defines th... Pin
Andrew Rissing14-Sep-11 3:53
memberAndrew Rissing14-Sep-11 3:53 
GeneralRe: not so much work to do this either. dgw.Scroll -= dgwSetupH... Pin
MrDeej20-Sep-11 10:17
memberMrDeej20-Sep-11 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170915.1 | Last Updated 15 Sep 2011
Article Copyright 2011 by A.J.Wegierski
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid