I have code which tries to connect a chat client to a server and if it fails, exits the application. I'm now trying to get the program to wait 2 mins and try again. I was thinking of starting a timer in the exception which would then make a call back to my function so that it keeps looping every 2mins until it actually connects. Any better suggestions/solutions?
Code:
Public Function ConnectToRemote(ByVal IP As IPAddress, ByVal port As Integer) As Boolean
Dim soc As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Try
soc.Connect(New IPEndPoint(IP, port))
g_socConnected = soc
BeginWaitForChat()
Return True
Catch ex As Exception
Application.Exit()
End Try
End Function