Dim Thread2 As New Thread(AddressOf Task2)private sub Task2()      
        Dim i As Integer
        Dim Client As New TcpClient
        Dim Buffer(256) As Byte
        While True
            Try
                Client.Connect("localhost", 9015)
            Catch ex As Exception
                If Client.Connected = False Then
                    Client.Close()
                    Client = New TcpClient
                End If
                GoTo line1
            End Try
            If Client.Connected = True Then
                While True
                    Try
                        Dim str As String = WindowsActive.Acitive.ToString
                        Buffer = System.Text.Encoding.UTF8.GetBytes(str)
                        If Client.Connected = False Then Exit While
                        Client.GetStream().Write(Buffer, 0, Buffer.Length)
                        WindowsActive.Acitive = 0 ' 窗体响应状态复位 ,0 无人响应, 1 有人响应
                        System.Threading.Thread.Sleep(9000)
                    Catch ex As Exception
                        Exit While
                    End Try
                End While
            End If
line1:
            System.Threading.Thread.Sleep(9000)
        End While
        Client.Close()
end sub