N
Nikolay Petrov
Let's say I have a class, which raises events:
Class eventRaiser
Public Event Event1()
Private WithEvents timer1 As System.Timers.Timer
Public Sub New()
With timer1
.Interval = 2000
.Enabled = True
End With
End Sub
Private Sub timer1_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles timer1.Elapsed
RaiseEvent Event1()
End Sub
End Class
Then In my app I declare variable with of type this class and then add
handler for the event. This work's fine.
I need a way to handle events from a collection of my class. Like if I
add many instances of my class in ArrayList or similiar.
How to handle the events raised from different classes in the
colletion?
Also the IDE doesn't allow me to declare a variable with "WithEvents"
in a procedure, only on class level.
Class eventRaiser
Public Event Event1()
Private WithEvents timer1 As System.Timers.Timer
Public Sub New()
With timer1
.Interval = 2000
.Enabled = True
End With
End Sub
Private Sub timer1_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles timer1.Elapsed
RaiseEvent Event1()
End Sub
End Class
Then In my app I declare variable with of type this class and then add
handler for the event. This work's fine.
I need a way to handle events from a collection of my class. Like if I
add many instances of my class in ArrayList or similiar.
How to handle the events raised from different classes in the
colletion?
Also the IDE doesn't allow me to declare a variable with "WithEvents"
in a procedure, only on class level.