Created
September 5, 2012 20:52
-
-
Save renatoeufe/3644557 to your computer and use it in GitHub Desktop.
Exemplo de Async/Await C# 4.5
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
using System; | |
using System.Threading.Tasks; | |
namespace Exemplo.AsyncAwait | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Exec(); | |
Console.ReadLine(); | |
} | |
static async void Exec() | |
{ | |
var task = Task.Run(() => SayHelloAsync()); | |
Console.WriteLine(await task); | |
} | |
static async Task<string> SayHelloAsync() | |
{ | |
return "Hello"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment