Raise event in New possible

  • Thread starter Thread starter active
  • Start date Start date
A

active

In a UserControl's New method if I call a routine that does a RaiseEvent
the event does not seen to get raised.

Am I correct in assuming that events are not raised until after New
completes?
Or am I misinterpreting what I'm seeing?


Cal
 
active said:
In a UserControl's New method if I call a routine that does a
RaiseEvent the event does not seen to get raised.

Am I correct in assuming that events are not raised until after
New completes?
Or am I misinterpreting what I'm seeing?

You are right. To add a handler to an object you must have a reference. You
get the reference from "New TheClass", so before the constructor hasn't
finished you can not add the handler.

One exception is when passing a delegate to the constructor and the
constructor adds it to the Event as an event handler.
 
* " active said:
In a UserControl's New method if I call a routine that does a RaiseEvent
the event does not seen to get raised.

Am I correct in assuming that events are not raised until after New
completes?
Or am I misinterpreting what I'm seeing?

Yes, because the event handlers are not added yet at the moment when
raising the event from the ctor.
 
Back
Top