Collection (hashtable) of objects that raise events

  • Thread starter Thread starter Jason L James
  • Start date Start date
J

Jason L James

Hi All,

I have a class (class 1) that raises a couple of events.

I also have another class (class 2) that contains a hashtable
of objects that are of type class 1.

Is there anyway of trapping the events raised by one
of the objects in the hashtable in class 2 and processing
the event in class 2?

Many thanks,

Jason.
 
Jason,

I don't see the problem as a sample (not a hashtable) roughly typed in this
message

\\\
Public class1
public sub new
dim obj2 as new class2
addhandler obj2.theEvent, AddressOf bla_Event
end sub
public sub bla_Event()
'do what you want
end sub
end class
Public class2
Public sub new
public event theEvent()
public tim as new timer
tim.enabled = true
tim.interval = 1000
addhandler obj2.theEvent, AddressOf bla_Event
end sub
public sub bla_Event
raise theEvent
end sub
////

I hope this helps?

Cor
 
Jason,

Jason L James said:
I have a class (class 1) that raises a couple of events.

I also have another class (class 2) that contains a hashtable
of objects that are of type class 1.

Is there anyway of trapping the events raised by one
of the objects in the hashtable in class 2 and processing
the event in class 2?

You can add a common handler for 'class1''s event using 'AddHandler' for
each instance of 'class1'. The event handler's 'sender' parameter will
contain a reference to the object that raised the event. 'RemoveHandler'
can be used to remove a handler.
 
Thanks Guys, I'll give it a go.

Jason.

Jason,



You can add a common handler for 'class1''s event using 'AddHandler' for
each instance of 'class1'. The event handler's 'sender' parameter will
contain a reference to the object that raised the event. 'RemoveHandler'
can be used to remove a handler.
 
Back
Top