Here's an overview. I want a sub called "ServerTimerElapsed" to run every 30 seconds. To do this, I'm using an event handler that triggers the above sub. The event handler works, and the sub runs. However, when it does run, it stops at the third line (dim stream...) and stops cold! No error message. It compiles without error. Any ideas? It works fine when not triggered by the event handler.
Here's the plan. I want to make the following happen.
Private Sub ServerTimerElapsed(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim SocketTest As Boolean
Dim HostEP As New System.Net.IPEndPoint(System.Net.Dns.GetHostByAddress(GlobalIP).AddressList(0), CurrentPort)
Dim Stream As New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)
Dim Progress As String
SocketTest = True
HostEP = New System.net.IPEndPoint(System.Net.Dns.GetHostByAddress(GlobalIP).AddressList(0), txtPortMon.Text)
Try
Stream.Connect(HostEP)
Catch ex As Exception
SocketTest = False
End Try
If SocketTest = True Then
lblMonStat.Text = FQDN & " running " & txtPortMon.Text
End If
End Sub
The event I want to trigger this is....
AddHandler ServerTimer.Elapsed, AddressOf ServerTimerElapsed
Here's the plan. I want to make the following happen.
Private Sub ServerTimerElapsed(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim SocketTest As Boolean
Dim HostEP As New System.Net.IPEndPoint(System.Net.Dns.GetHostByAddress(GlobalIP).AddressList(0), CurrentPort)
Dim Stream As New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)
Dim Progress As String
SocketTest = True
HostEP = New System.net.IPEndPoint(System.Net.Dns.GetHostByAddress(GlobalIP).AddressList(0), txtPortMon.Text)
Try
Stream.Connect(HostEP)
Catch ex As Exception
SocketTest = False
End Try
If SocketTest = True Then
lblMonStat.Text = FQDN & " running " & txtPortMon.Text
End If
End Sub
The event I want to trigger this is....
AddHandler ServerTimer.Elapsed, AddressOf ServerTimerElapsed