bbimis
asked on
How do you restart a timer in vb.net
how do you restart a timer in vb.net?
i have tried timer1.stop then timer1.start i have tried timer1.enabled = false then timer1.enabled = true nothing seems to work
i have tried timer1.stop then timer1.start i have tried timer1.enabled = false then timer1.enabled = true nothing seems to work
Calling Stop and Start should do the trick? Why do you say it is not working? Any code to share?
ASKER
here is what i have i have a timer1 and it starts on the form load and then the tick event is as follows
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
thread1 = New Thread(New ThreadStart(AddressOf checker))
thread1.Start()
End Sub
Public Sub checker()
Dim stop1 As Integer = 0
Try
If My.Computer.Network.Ping(server.ToString()) Then
tssStatus.Text = "Currently Online"
'Me.Refresh()
If stop1 = 1 Then
Timer1.Stop()
End If
End If
Catch ex As Exception
tssStatus.Text = "Offline"
' Me.Refresh()
stop1 = 1
End Try
End Sub
Private Sub ServerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ServerToolStripMenuItem.Click
My.Settings.Server = InputBox("Enter Server name", "Server Name")
Try
thread1.Abort()
Catch ex As Exception
End Try
Timer1.Enabled = False
Timer1.Enabled = True
Timer1.Start()
tsbWhichServer.Text = "Using: " & My.Settings.Server.ToString()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks i got it working. i had to put the server name in the inputbox section of the code. basically it wasn't updating the servername.
thanks for your help!
thanks for your help!