Skip to content

Instantly share code, notes, and snippets.

@ZhangSen1
Last active October 23, 2017 06:54
Show Gist options
  • Save ZhangSen1/3836caed1879a56e7f01 to your computer and use it in GitHub Desktop.
Save ZhangSen1/3836caed1879a56e7f01 to your computer and use it in GitHub Desktop.
async,await.cs
static void Main(string[] args)
{
DisplayAsync();
Console.Write("1");
}
public static Task<int> GetTaskAsync()
{
return Task.Run(() =>
{
var aa = 2;
for (var i = 0; i < 10000; i++)
{
aa = i;
}
return aa;
});
}
public static async void DisplayAsync()
{
var value = await GetTaskAsync();
Console.Write(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment