/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System.Threading/Thread/Overview/fsharp/Instance1.fs
55 строк
2 KB
Genevieve Warren
Add remarks for core types (#38970)
05 янв 2024, 22:14
Не верифицирован
05 янв 2024, 22:14
71d1377
Код
Авторство
О чём код?
module Instance1 // <Snippet4> open System.Threading let obj = obj () let showThreadInformation (state: obj) = lock obj (fun () -> let th = Thread.CurrentThread printfn $"Managed thread #{th.ManagedThreadId}: " printfn $" Background thread: {th.IsBackground}" printfn $" Thread pool thread: {th.IsThreadPoolThread}" printfn $" Priority: {th.Priority}" printfn $" Culture: {th.CurrentCulture.Name}" printfn $" UI culture: {th.CurrentUICulture.Name}" printfn "") ThreadPool.QueueUserWorkItem showThreadInformation |> ignore let th1 = Thread(ParameterizedThreadStart showThreadInformation) th1.Start() let th2 = Thread(ParameterizedThreadStart showThreadInformation) th2.IsBackground <- true th2.Start() Thread.Sleep 500 showThreadInformation () // 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>