title: Activating timer from another thread
body: <p>So the purpose of it is to check the connection of the ftp server and if the ftp is up then enable timer1. I've read that threads don't work as synchonized and that is causing the problem. Without the thread it works fine, but the program hangs and stops responding constantly.</p>
  
  <p>How can i activate a timer from another thread?
  Maybe invoking and delegating would work? But i don't know how to do that.</p>
  
  <pre><code>Public Function CanPortOpen(ByVal HostName As String, ByVal Port As Integer) As Boolean
      Dim TCP As New System.Net.Sockets.TcpClient
      Try
          TCP.Connect(HostName, Port)
      Catch
      End Try
      If TCP.Connected = True Then
          CanPortOpen = True
          TCP.Close()
          Timer1.Enabled = True
      Else
          CanPortOpen = False
          TCP.Close()
          Timer1.Enabled = False
          FTPup.Abort()
      End If
  End Function
  
  Public Sub CheckConnection()
      CanPortOpen("HostName", Port)
  End Sub
  
  Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
      TestFTP = New System.Threading.Thread(AddressOf CheckConnection)
      TestFTP.IsBackground = True
      TestFTP.Priority = Threading.ThreadPriority.AboveNormal
      TestFTP.Start()
  End Sub
  
  Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
      FTPup = New System.Threading.Thread(AddressOf UploadToFTP)
      FTPup.IsBackground = True
      FTPup.Priority = Threading.ThreadPriority.AboveNormal
      FTPup.Start()
  End Sub
  </code></pre>