Events

  • Thread starter Thread starter Nikolay Petrov
  • Start date Start date
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.
 
Ok, Cor I know this. But how to add handler for an item, which raised
events, if this item is in collection, like ArrayList or similiar?
 
Nikolay,

How can an item raise an event and why would it do that.

An item an be the reason for a call of a method

If Item = "Nicolay" then help("I don't undrstand what he means")

Therefore give some sample code?

Cor
 
No offence, but I don't see what you don't understand Cor.
I've found what I was looking for.
Thanks however.
 
Back
Top