我正在使用以下代码尝试连接到系统,但处理超时。当没有连接时,tcpClient.Connected会在一段时间后给出NullReferenceException
If tcpClient.ConnectAsync(IP, Port).Wait(1000) = False Then
'Messagebox error
End If
If tcpClient.Connected Then
.....
End if
堆栈跟踪
bij System.Net.Sockets.TcpClient.get_Connected()
bij directory\System.vb:regel 47
bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bij System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)