RaiseEvent

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

I have a class named cDevice. I have a Generic Dictionary "Devices" that
holds
many cDevice(s). My cDevice class has callbacks(RaiseEvents).
How can I get callbacks from all the cDevice objects in my dictionary?

I only get one callback because I Do;
Private WithEvents CurrentDevice as cDevice
CurrentDevice=Devices.item(i)

So I only get the callbacks for that one cDevice..CurrentDevice.

How Do I get callbacks for all cDevice in Devices?

-Lou
 
How Do I get callbacks for all cDevice in Devices?

Use AddHandler and RemoveHandler to attach event handlers to each device in
your collection.

Like:

For Each d As cDevice In Devices
AddHandler(d.SomeEvent, Addressof EventHandler)
Next

Sub EventHandler(sender As Object, e As EventArgs)
....
End Sub


-h-
 
Each of my cDevice objects already have callbacks.
With your suggestion do I receive the callback from the
Devices or Device?
 
Each of my cDevice objects already have callbacks.
With your suggestion do I receive the callback from the
Devices or Device?

For each cDevice in Devices, obviously.

-h-
 
Back
Top