/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/standard/parallel-programming/snippets/cs/result1.cs
29 строк
838 B
dotnet-bot
Add missing byte order marks to C# and VB code
04 авг 2020, 20:44
04 авг 2020, 20:44
f7e06a2
Код
Авторство
О чём код?
using System; using System.Threading.Tasks; public class ResultExample { public static async Task Main() { var task = Task.Run( () => { DateTime date = DateTime.Now; return date.Hour > 17 ? "evening" : date.Hour > 12 ? "afternoon" : "morning"; }); await task.ContinueWith( antecedent => { Console.WriteLine($"Good {antecedent.Result}!"); Console.WriteLine($"And how are you this fine {antecedent.Result}?"); }, TaskContinuationOptions.OnlyOnRanToCompletion); } } // The example displays the similar output: // Good afternoon! // And how are you this fine afternoon?