Imports System.Threading
public class Test
public Shared Sub Main
Dim msg As String : Dim i As Integer
Dim job As New MyJob()
For i = 1 To 5
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf job.MyTask), i)
Next
Thread.Sleep(2000)
End Sub
End class
Public Class MyJob
Private Msg As String
Dim availWorker As Integer = 0 : Dim maxWorker As Integer = 0
Dim availCPT As Integer = 0 : Dim maxCPT As Integer = 0
Public Sub MyTask(ByVal ThreadStateData As Object)
Console.WriteLine("Performing Task. Data Passed: " & ThreadStateData)
ThreadPool.GetAvailableThreads(availWorker, availCPT)
ThreadPool.GetMaxThreads(maxWorker, maxCPT)
Console.WriteLine("--Available Worker Threads: " & availWorker.ToString())
Console.WriteLine("--Maximum Worker Threads: " & maxWorker.ToString())
Console.WriteLine("--Available Completion Port Threads: " & availCPT.ToString())
Console.WriteLine("--Maximum Completion Port Threads: " & maxCPT)
End Sub
End Class
|