Imports System.IO
Public Class Form1
Public t As Timer
Private mtimers() As Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReDim mtimers(1)
For i As Integer = 0 To 1
t = New Timer
t.Interval = 1000 * (i + 1)
t.Enabled = True
t.Tag = i + 1
AddHandler t.Tick, AddressOf Timer_Tick
mtimers(i) = t
Next
End Sub
Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs)
Dim timer As Timer = DirectCast(sender, Timer)
Select Case timer.Tag
Case "1"
Dim sw As New StreamWriter("test1.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
'timer.Stop()
Case "2"
'MessageBox.Show("TAG 2")
Dim sw As New StreamWriter("test2.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
End Select
End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
For Each t As Timer In mtimers
t.Stop()
Next
End Sub
End Class
fuente1
fuente2
fuente3
No hay comentarios.:
Publicar un comentario