Ivan,
Are you doing this inside or outside of the class that is exposing the
event. If it is outside, then you would have to use reflection to get to
the delegate that is being stored internally (the C# compiler will not let
an event appear on the right hand side of an assignment expression).
If this is internal, then you can use the syntax for events which allows
you to write extra code, like so:
// Need to store the event in a field to prevent compiler error.
// Also, you will have to check against null when you want to use it.
private EventHandler myEvent;
public event EventHandler MyEvent
{
add
{
// Write code to check the value (like in a property)
// to see if the event handler points to a method info you might
// already have in your invocation list.
// If the check succeeds, then add the handler.
myEvent += value;
}
remove
{
// Remove the delegate.
MyEvent -= value;
}
}
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Ivan" <iv*********@dynamic-imaging.com> wrote in message
news:e5**************@tk2msftngp13.phx.gbl...
subject says it all.
thanks in advance.
Ivan