title: multi-threaded proxy checker having problems
body: <p>I am trying to create a proxy checker.
  This is my first attempt at multithreading and it's not going so well, the threads seem to be waiting for one to complete before initializing the next.</p>
  
  <pre><code>Imports System.Net
  Imports System.IO
  Imports System.Threading
  
  Public Class Form1
      Public sFileName As String
      Public srFileReader As System.IO.StreamReader
      Public sInputLine As String
  
      Public Class WebCall
          Public proxy As String
          Public htmlout As String
  
          Public Sub New(ByVal proxy As String)
              Me.proxy = proxy
          End Sub
  
          Public Event ThreadComplete(ByVal htmlout As String)
  
          Public Sub send()
              Dim myWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.myserver.com/ip.php"), HttpWebRequest)
              myWebRequest.Proxy = New WebProxy(proxy, False)
              Try
                  Dim myWebResponse As HttpWebResponse = CType(myWebRequest.GetResponse(), HttpWebResponse)
                  Dim loResponseStream As StreamReader = New StreamReader(myWebResponse.GetResponseStream())
                  htmlout = loResponseStream.ReadToEnd()
                  Debug.WriteLine("Finished - " &amp; htmlout)
                  RaiseEvent ThreadComplete(htmlout)
              Catch ex As WebException
                  If (ex.Status = WebExceptionStatus.ConnectFailure) Then
                  End If
                  Debug.WriteLine("Failed - " &amp; proxy)
              End Try
          End Sub
      End Class
  
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Dim proxy As String
          Dim webArray As New ArrayList()
          Dim n As Integer
          For n = 0 To 2
              proxy = srFileReader.ReadLine()
              webArray.Add(New WebCall(proxy))
          Next
  
          Dim w As WebCall
          For Each w In webArray
              Threading.ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf w.send), w)
          Next w
  
      End Sub
  
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          srFileReader = System.IO.File.OpenText("proxies.txt")
      End Sub
  End Class
  </code></pre>