/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System.Threading/Thread/Overview/vb/Instance1.vb
62 строки
2 KB
Genevieve Warren
Move member remarks (#39270)
30 янв 2024, 00:43
Не верифицирован
30 янв 2024, 00:43
6c88824
Код
Авторство
О чём код?
' Visual Basic .NET Document Option Strict On ' <Snippet4> Imports System.Threading Module Example2 Private lock As New Object() Public Sub Main() ThreadPool.QueueUserWorkItem(AddressOf ShowThreadInformation) Dim th1 As New Thread(AddressOf ShowThreadInformation) th1.Start() Dim th2 As New Thread(AddressOf ShowThreadInformation) th2.IsBackground = True th2.Start() Thread.Sleep(500) ShowThreadInformation(Nothing) End Sub Private Sub ShowThreadInformation(state As Object) SyncLock lock Dim th As Thread = Thread.CurrentThread Console.WriteLine("Managed thread #{0}: ", th.ManagedThreadId) Console.WriteLine(" Background thread: {0}", th.IsBackground) Console.WriteLine(" Thread pool thread: {0}", th.IsThreadPoolThread) Console.WriteLine(" Priority: {0}", th.Priority) Console.WriteLine(" Culture: {0}", th.CurrentCulture.Name) Console.WriteLine(" UI culture: {0}", th.CurrentUICulture.Name) Console.WriteLine() End SyncLock End Sub End Module ' The example displays output like the following: ' ' Managed thread #6: ' Background thread: True ' Thread pool thread: False ' Priority: Normal ' Culture: en-US ' UI culture: en-US ' ' Managed thread #3: ' Background thread: True ' Thread pool thread: True ' Priority: Normal ' Culture: en-US ' UI culture: en-US ' ' Managed thread #4: ' Background thread: False ' Thread pool thread: False ' Priority: Normal ' Culture: en-US ' UI culture: en-US ' ' Managed thread #1: ' Background thread: False ' Thread pool thread: False ' Priority: Normal ' Culture: en-US ' UI culture: en-US ' </Snippet4>