Raise events in a class.new statement dows not fire???

  • Thread starter Thread starter Peter van der Veen
  • Start date Start date
P

Peter van der Veen

Hi

I have a class with an error event.

When i initialize the class from a program the events in the class new
sub does not fire. (i don't get them back)
When calling anonther sub in the same class the events fires without
problems.

How can i get the events raised in the class new sub?
Or is it not possible.

Peter
 
Peter,

You can raise it, but there can't be any event handlers registered for
the event at that point, so it's kinda pointless.

What kind of event do you need to raise from the constructor? You
could possibly pass a delegate to the constructor and use that to
notify the handler.



Mattias
 
Hi Peter,

This is not possible. While a class instance is being constructed, the
subscribers haven't had a chance to subscribe to the instance events yet as
instance construction is still in progress.
 
* Peter van der Veen said:
I have a class with an error event.

When i initialize the class from a program the events in the class new
sub does not fire. (i don't get them back)

That's because the instance of the class isn't completely constructed
and no handlers are registered at that time.
 
Thx

So i have to port the code in the new constructor to a new sub and
call it afterwards.

Peter
 
Back
Top