/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/standard/parallel-programming/snippets/cs/simple1.cs
16 строк
499 B
David Pine
Address concerns about chaining tasks and lacking continuation examples with .Unwrap() (#19611)
28 июл 2020, 15:00
Не верифицирован
28 июл 2020, 15:00
9685f88
Код
Авторство
О чём код?
using System; using System.Threading.Tasks; public class SimpleExample { public static async Task Main() { // Declare, assign, and start the antecedent task. Task<DayOfWeek> taskA = Task.Run(() => DateTime.Today.DayOfWeek); // Execute the continuation when the antecedent finishes. await taskA.ContinueWith(antecedent => Console.WriteLine($"Today is {antecedent.Result}.")); } } // The example displays the following output: // Today is Monday.