title: Async Socket Listener on separate thread - VB.net
body: <p>I am trying to use the code from Microsoft for an Async Socket connection. It appears the listener runs in the main thread locking the GUI. I am new at both socket connections and multi-threading all at the same time. Having a hard time getting my mind wrapped around this all at once.</p>
  
  <p>The code used is at <a href="http://msdn.microsoft.com/en-us/library/fx6588te.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/fx6588te.aspx</a>
  <strong>Using this example, how can I move the listener to its own thread?</strong> </p>
  
  <pre><code> Public Shared Sub Main()
      ' Data buffer for incoming data.
      Dim bytes() As Byte = New [Byte](1023) {}
  
      ' Establish the local endpoint for the socket.
      Dim ipHostInfo As IPHostEntry = Dns.GetHostEntry(Dns.GetHostName())
      Dim ipAddress As IPAddress = ipHostInfo.AddressList(1)
      Dim localEndPoint As New IPEndPoint(ipAddress, 11000)
  
      ' Create a TCP/IP socket.
      Dim listener As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
  
      ' Bind the socket to the local endpoint and listen for incoming connections.
      listener.Bind(localEndPoint)
      listener.Listen(100)
  </code></pre>