/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadStart2/VB/source3.vb
46 строк
1 KB
Andy De George
Move snippets from samples repo to this repo (#17296)
03 мар 2020, 19:23
Не верифицирован
03 мар 2020, 19:23
dbbeda1
Код
Авторство
О чём код?
'<snippet3> Imports System.Threading ' The ThreadWithState class contains the information needed for ' a task, and the method that executes the task. Public Class ThreadWithState ' State information used in the task. Private boilerplate As String Private numberValue As Integer ' The constructor obtains the state information. Public Sub New(text As String, number As Integer) boilerplate = text numberValue = number End Sub ' The thread procedure performs the task, such as formatting ' and printing a document. Public Sub ThreadProc() Console.WriteLine(boilerplate, numberValue) End Sub End Class ' Entry point for the example. ' Public Class Example Public Shared Sub Main() ' Supply the state information required by the task. Dim tws As New ThreadWithState( _ "This report displays the number {0}.", 42) ' Create a thread to execute the task, and then ' start the thread. Dim t As New Thread(New ThreadStart(AddressOf tws.ThreadProc)) t.Start() Console.WriteLine("Main thread does some work, then waits.") t.Join() Console.WriteLine( _ "Independent task has completed main thread ends.") End Sub End Class ' The example displays the following output: ' Main thread does some work, then waits. ' This report displays the number 42. ' Independent task has completed; main thread ends. '</snippet3>