Is it possible to pass an object to a thread? I tried the following, but it didn't work...

VB Code:
  1. Public Sub StartTCPConnection()
  2.         Dim HandleThread As Thread
  3.         Try
  4.             ' Set the TcpListener on port 13000.
  5.             Dim localAddr As IPAddress = IPAddress.Parse("127.0.0.1")
  6.             Dim port As Int32 = 13000
  7.             Server = New TcpListener(localAddr, port)
  8.  
  9.             ' Start listening for client requests.
  10.             Server.Start()
  11.  
  12.             While True
  13.                 Debug.Write("Waiting for a connection... ")
  14.                 ' Perform a blocking call to accept requests.
  15.                 ' You could also user server.AcceptSocket() here.
  16.                 Dim Client As TcpClient = Server.AcceptTcpClient
  17.                 [b]HandleThread = New Thread(AddressOf HandleConnection(Client))[/b]
  18.                 HandleThread.Start()
  19.                 Client.Close()
  20.             End While
  21.         Catch ex As SocketException
  22.             Debug.WriteLine("socketexeption:", ex.ToString)
  23.         End Try
  24.     End Sub
  25.  
  26.     Public Sub HandleConnection(ByVal Client As TcpClient)
  27.         ' Buffer for reading data
  28.         Dim bytes(1024) As [Byte]
  29.         Dim data As [String] = Nothing
  30.  
  31.  
  32.         Debug.WriteLine("Connected!")
  33.  
  34.         data = Nothing
  35.  
  36.         ' Get a stream object for reading and writing
  37.         Dim stream As NetworkStream = Client.GetStream()
  38.  
  39.         Dim i As Int32
  40.  
  41.         ' Loop to receive all the data sent by the client.
  42.         i = 0
  43.         i = stream.Read(bytes, 0, bytes.Length)
  44.         ' Translate data bytes to a ASCII string.
  45.         data = System.Text.Encoding.ASCII.GetString(bytes, 0, i)
  46.         Debug.WriteLine([String].Format("Received: {0}", data))
  47.  
  48.         ' Process the data sent by the client.
  49.         data = CheckValidity(data.ToUpper)
  50.  
  51.         Dim msg As [Byte]() = System.Text.Encoding.ASCII.GetBytes(data)
  52.  
  53.         ' Send back a response.
  54.         stream.Write(msg, 0, msg.Length)
  55.         debug.WriteLine([String].Format("Sent: {0}", data))
  56.  
  57.         ' Shutdown and end connection
  58.         Client.Close()
  59.     End Sub

what is the correct way to do this?

thanx in advance,

SQ1