Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Class MyTimer
Inherits Control
Private WithEvents FTimer As System.Windows.Forms.Timer
Public Shadows Property Enabled() As Boolean
Get
Return FTimer.Enabled
End Get
Set(ByVal value As Boolean)
FTimer.Enabled = value
End Set
End Property
Public Property Interval() As Integer
Get
Return FTimer.Interval
End Get
Set(ByVal value As Integer)
FTimer.Interval = value
End Set
End Property
Public Sub Start()
FTimer.Start()
End Sub
Public Sub [Stop]()
FTimer.Stop()
End Sub
Public Event Tick(ByVal sender As MyTimer, ByVal e As System.EventArgs)
Public Sub New()
FTimer = New System.Windows.Forms.Timer
End Sub
Private Sub FTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FTimer.Tick
RaiseEvent Tick(Me, e)
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
Dim ButtonSuffix As String = CType(sender, Button).Name.Substring("Button".Length)
For Each c As Control In Controls
If TypeOf c Is MyTimer Then
If c.Name.EndsWith(ButtonSuffix) Then
CType(c, MyTimer).Start()
Exit Sub
End If
End If
Next
End Sub
Private Sub MyTimer1_Tick(ByVal sender As MyTimer, ByVal e As System.EventArgs) Handles MyTimer1.Tick, MyTimer2.Tick, MyTimer3.Tick
CType(sender, MyTimer).Stop()
MessageBox.Show(CType(sender, MyTimer).Name)
End Sub
End Class
Public Event Tick(ByVal sender As [s]MyTimer[/s] [b]Object[/b], ByVal e As System.EventArgs)
Public Sub New()
FTimer = New System.Windows.Forms.Timer
End Sub
Private Sub MyTimer1_Tick(ByVal sender As [s]MyTimer[/s] [b]Object[/b], ByVal e As System.EventArgs) Handles MyTimer1.Tick, MyTimer2.Tick, MyTimer3.Tick
CType(sender, MyTimer).Stop()
MessageBox.Show(CType(sender, MyTimer).Name)
End Sub
I have created one Tick routine for several timers. I need to know which Timer executed the Tick routine so I can Stop that Timer if a certain condition has been met.