/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System.Threading.Tasks/Task/Overview/fsharp/Wait2.fs
25 строк
661 B
Genevieve Warren
Add remarks for core types (#38970)
05 янв 2024, 22:14
Не верифицирован
05 янв 2024, 22:14
71d1377
Код
Авторство
О чём код?
module Wait2 // <Snippet9> open System open System.Threading open System.Threading.Tasks // Wait on a single task with a timeout specified. let taskA = Task.Run(fun () -> Thread.Sleep 2000) try taskA.Wait 1000 |> ignore // Wait for 1 second. let completed = taskA.IsCompleted printfn $"Task A completed: {completed}, Status: {taskA.Status}" if not completed then printfn "Timed out before task A completed." with :? AggregateException -> printfn "Exception in taskA." // The example displays output like the following: // Task A completed: False, Status: Running // Timed out before task A completed. // </Snippet9>