Imports System
Imports System.Threading
Public Class MyData
Public MyStringValue As String
Public Value As Integer
Public Sub New(text As String, number As Integer)
MyStringValue = text
Value = number
End Sub
End Class
Public Class Example
Public Shared Sub Main()
Dim ti As New MyData("value", 42)
If ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf ThreadProc), ti) Then
Thread.Sleep(1000)
Else
Console.WriteLine("Unable to queue ThreadPool request.")
End If
End Sub
Shared Sub ThreadProc(stateInfo As Object)
Dim ti As MyData = CType(stateInfo, MyData)
Console.WriteLine(ti.MyStringValue, ti.Value)
End Sub
End Class
|