Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Threading
Imports System.Net.Sockets
Module Module1
Sub Main()
'Set number of threads to be created for testing.
Dim testThreads As Integer = 55
Dim i As Integer
For i = 0 To testThreads
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf PoolFunc))
Next
Console.ReadLine()
End Sub
Public Sub PoolFunc(ByVal state As Object)
Dim workerThreads, completionPortThreads As Integer
ThreadPool.GetAvailableThreads(workerThreads, completionPortThreads)
Console.WriteLine("WorkerThreads: {0}, CompletionPortThreads: {1}", workerThreads, completionPortThreads)
Thread.Sleep(10000)
Dim url As String = "http://www.msn.com"
Dim myHttpWebRequest As HttpWebRequest
Dim myHttpWebResponse As HttpWebResponse = Nothing
' Creates an HttpWebRequest for the specified URL.
myHttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
'Sends the HttpWebRequest, and waits for a response.
myHttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
myHttpWebResponse.Close()
End Sub
End Module