Created
October 9, 2018 20:36
-
-
Save pedrovasconcellos/94d705d851042719aec0d718ee1a7dac to your computer and use it in GitHub Desktop.
Exemplo de continuação de Task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
Task<DayOfWeek> tarefa = new Task<DayOfWeek>(delegate() { return DateTime.Today.DayOfWeek; }); | |
// A continuacao. Seu delegate toma a tarefa antecedente | |
// como um argumento e pode retornar um tipo diferente | |
Task<string> continuacao = tarefa.ContinueWith((antecedent) => | |
{ | |
return String.Format("Hoje é {0}.",antecedent.Result); | |
}); | |
// Iniciar a antecedente | |
tarefa.Start(); | |
// Usar o resultada da continuacao | |
Console.WriteLine(continuacao.Result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment