Q: vb 2010 - I need to make 1000 http posts asyncronously. Using VB.NET 2010 - I'm kind of new to this and trying to build a load tester.  Here is what I have so far (which is working, but not posting asynchronously.  I'm looping through my posts(500 or so) that I have in an array.  This is returning info back from the server asynchronously.  How can I set it up to push 2 or more files up synchronously while looping through?
Imports System.Data
Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Threading

Public Class Form1

    Private Sub btnStart_Click(sender As System.Object, e As System.EventArgs) Handles btnStart.Click
        lblError.Text = ""
        lblStatusMsg.Text = "Send Status..."
        lblConnectionStatus.Text = "Connection Status..."
        getData("test_post_data_1000.csv")

    End Sub

    Private strQuery As New StringBuilder
    Private path As String
    Private myPosts(999) As String          ' an array of the parsed csv which is ready to be posted
    Private csvDS As New DataSet
    Private loopCount As Integer            ' keeps track of the number of csv rows parsed
    Private connectionLimit As String
    Private currentConnections As String
    Private postsSent As Integer            ' keeps track of the number of posts sent in the loop

    Public Sub SendAsynchRequest()

        Dim request As HttpWebRequest
        Dim thePost As String
        Dim hashcode As Integer = 0

        Try
            Dim myURI As New Uri("http://myImportSite.aspx")

            ' For x = 0 To myPosts.Length - 1
            For x = 0 To 9
                ' Create the request
                request = CType(WebRequest.Create(myURI), HttpWebRequest)
                request.Method = "POST"
                request.ContentType = "application/x-www-form-urlencoded"

                Dim currentServicePoint As ServicePoint = request.ServicePoint

                ' Display new service point properties.
                Dim currentHashCode As Integer = currentServicePoint.GetHashCode()
                lblConnectionStatus.Text = "New service point hashcode: " + currentHashCode.ToString() & vbCr
                lblConnectionStatus.Text = lblConnectionStatus.Text & "New service point max idle time: " + currentServicePoint.MaxIdleTime.ToString() & vbCr

                ' Check that a new ServicePoint instance has been created.
                If hashcode = currentHashCode Then
                    lblConnectionStatus.Text = lblConnectionStatus.Text & "Service point reused.  Count = " & request.ServicePoint.CurrentConnections
                Else
                    lblConnectionStatus.Text = lblConnectionStatus.Text & "Service Point - Current Connections = " & request.ServicePoint.CurrentConnections
                End If
                Me.Refresh()

                request.ServicePoint.ConnectionLimit = 10 ' default is 2 and will only allow 2 posts
                request.ServicePoint.MaxIdleTime = 2000 'sets the maximum idle time to 2 seconds

                thePost = myPosts(x)
                ' Convert the string into a byte array
                Dim bytes As Byte()
                bytes = System.Text.Encoding.UTF8.GetBytes(thePost)

                ' Assign the content length
                request.ContentLength = bytes.Length ' byle length should be about 378 for first record


                ' Write the postData bytes to request stream
                request.GetRequestStream.Write(bytes, 0, bytes.Length)
                postsSent = x + 1

                Dim result As IAsyncResult
                Dim state As WebRequestState
                Dim timeout As Integer

                ' Create the state object used to access the web request
                state = New WebRequestState(request)

                ' Begin the async request
                connectionLimit = request.ServicePoint.ConnectionLimit
                currentConnections = request.ServicePoint.CurrentConnections
                result = request.BeginGetResponse(New AsyncCallback(AddressOf RequestComplete), state)

                ' Set timeout at 30 seconds
                timeout = 1000 * 60

                ' Register a timeout for the async request
                ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, New WaitOrTimerCallback(AddressOf TimeoutCallback), state, timeout, True)
            Next
        Catch e As Exception
            lblError.Text = "Source : " + e.Source & vbCr & _
                "Message : " + e.Message
        Finally
            'If Not (request Is Nothing) Then
            '    request.close()
            'End If
        End Try


    End Sub

    ' Method called when a request times out
    Private Sub TimeoutCallback(ByVal state As Object, ByVal timeOut As Boolean)
        If (timeOut) Then
            lblError.Text = "Your request timed out!"
            ' Abort the request
            CType(state, WebRequestState).Request.Abort()

        End If
    End Sub

    ' Method called when the request completes
    Private Sub RequestComplete(ByVal result As IAsyncResult)
        ' Get the request

        Dim request As WebRequest
        request = DirectCast(result.AsyncState, WebRequestState).Request

        lblStatusMsg.Text = "Your request is processing..." & vbCr & "Looping through .CSV = " & loopCount & vbCr & vbCr & "Connection Limit = " & connectionLimit & _
            vbCr & vbCr & "Posts sent = " & postsSent & vbCr & "Current Connections = " & currentConnections
        If postsSent = 39 Then
            btnStart.Text = "DONE!"
            btnStart.BackColor = Color.Fuchsia
        End If
        Me.Refresh()
        Me.Focus()
    End Sub

    ' Stores web request for access during async processing
    Private Class WebRequestState
        ' Holds the request object
        Public Request As WebRequest

        Public Sub New(ByVal newRequest As WebRequest)
            Request = newRequest
        End Sub
    End Class
End Class


A: Thread pool or Threads in general are what you need.
Example of ThreadPool manner to queue background work tasks.
Public Sub Queue1000WorkTasks()
    Threading.ThreadPool.SetMaxThreads(1000, 1000)
    For iQ As Integer = 1 To 1000
        Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(AddressOf DoWork_Async), Nothing)
    Next
End Sub

Public Sub DoWork_Async(notUsed As Object)
    'process something here...
End Sub

Same thing with Normal Threads...
Public Sub Queue1000WorkTasks()
    For iQ As Integer = 1 To 1000
        Dim th As New Threading.Thread(AddressOf DoWork_Async, Nothing)
        th.Start()
    Next
End Sub

Public Sub DoWork_Async(notUsed As Object)
    'process something here...
End Sub

Have never queued 1000 items at the same time like this before, so have no idea what you can expect from your system.
Possibly try a smaller number first.
