Why don't events raise in Sub New?

  • Thread starter Thread starter IcedCrow
  • Start date Start date
I

IcedCrow

Subject says it all. I want to raise an event in Sub New
of a class but it is not being raised to my client app.

I can raise events just fine in other procedures... just
not sub new.

Why is this?

Thanks in advance!
 
IcedCrow,
As steve stated, because the object itself is not fully instantiated, which
means that no event handlers have been connected to it yet. as the calling
routine has not received the object yet to add handlers to its events.

The only why that I know of to "raise an event" from Sub New is to pass a
delegate or object as a parameter to the constructor then the constructor
itself calls the delegate or uses AddHandler (directly or indirectly) to the
object that was passed in. After the handlers are connect, then the
constructor can raise the event.

Hope this helps
Jay
 
Back
Top