Sets or gets a numeric value that can be used as a parameter for a thread.
thread_object.Argument = <numeric_value>
-or-
... thread_object.Argument
Prerequisites
None
Parameters
None
Remarks
This property associates a numeric value with a particular thread. The value may be set prior to the execution of a thread and can be accessed by the thread during its execution, thus serving as a parameter for the thread. This value may also be changed while the thread is executing, but that is not its intended use.
For example, this value can be interpreted as an index to access an element of an array that contains data for a thread.
Examples
Public ThreadData(16) As String
Public Sub MAIN
Dim t1 As New Thread("Test", , "Thread1")
Dim t2 As New Thread("Test", , "Thread2")
ThreadData(1)= "Thread data 1"
ThreadData(2)= "Thread data 2"
t1.Argument = 1
t1.Start
t2.Argument = 2
t2.Start
End Sub
' The following thread writes "Thread data 1" then
' "Thread data 2"
Public Sub Test
Dim index As Integer
index = Thread.CurrentThread.Argument
Console.WriteLine(ThreadData(index))
End Sub
See Also
Thread Class | Thread.CurrentThread | thread_object.Name|thread_object.Start