V
Vincent
Hi,
I was trying to do something in a Thread that starts by a
timer. I turn off the timer at the begining of the thread
incase it fires again when the thread is still running. Then
turn on the timer again before the thread finishes. To my
surprise, the timer never come alive again once it has been
turned of in the thread. To test the problem I made a simple
Windows Form project, put a Beep() in the timer. It supposed
to hear beep beep beep every one seconds, but can only hear
one. Here enclosed my clode below. Any help or suggestions are
really appreciated.
Regards,
Vincent
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Timer1.Tick
Beep()
Dim thr As New Threading.Thread(AddressOf ProcTest)
thr.Start()
End Sub
Private Sub ProcTest()
Timer1.Enabled = False
'Timer1.Stop()
Timer1.Enabled = True
'Timer1.Start()
End Sub
I was trying to do something in a Thread that starts by a
timer. I turn off the timer at the begining of the thread
incase it fires again when the thread is still running. Then
turn on the timer again before the thread finishes. To my
surprise, the timer never come alive again once it has been
turned of in the thread. To test the problem I made a simple
Windows Form project, put a Beep() in the timer. It supposed
to hear beep beep beep every one seconds, but can only hear
one. Here enclosed my clode below. Any help or suggestions are
really appreciated.
Regards,
Vincent
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Timer1.Tick
Beep()
Dim thr As New Threading.Thread(AddressOf ProcTest)
thr.Start()
End Sub
Private Sub ProcTest()
Timer1.Enabled = False
'Timer1.Stop()
Timer1.Enabled = True
'Timer1.Start()
End Sub