Hi
If I connect
thingi.Event += new EventHandler(CallBackFunction);
how can I check wich callback functions are connected to the thingi.Event?
Now I just try to remove every connection and then establish the new one. Is there a better way?
GMarco
Printable View
Hi
If I connect
thingi.Event += new EventHandler(CallBackFunction);
how can I check wich callback functions are connected to the thingi.Event?
Now I just try to remove every connection and then establish the new one. Is there a better way?
GMarco
As far as I know, the only way of keeping track of your eventhandlers is by adding them to a collection when you assign them.
something like:
Then you'll have a list of eventhandlers that you can check - you would need to do this for each object though.Code:
EventHandler eh = new EventHandler(MyMethod);
myObject.Event += eh;
myEvents.Add(eh);
Instead of having:
just do:Code:public event EventHandler Foo;
Then you can iterate over 'foo' and remove eventhandlers you don't need, set it to null to clear everything, or whatever it is you want to do. There are probably better ways of doing it though.Code:EventHandler foo;
public event EventHandler Foo {
add { foo += value; }
remove { foo -= value; }
}