2016년 8월 30일 화요일

c# Task Async Await Basic Example




private void button1_Click(object sender, EventArgs e)
{
Mymethodasync();
}

public async Task Mymethodasync()
{
Console.WriteLine("1");
Task llrr = longrun();
Console.WriteLine("2");
int output = await llrr;
Console.WriteLine("3");

}

public async Task longrun()
{
Console.WriteLine("longrun Task");
await Task.Delay(1000);
Console.WriteLine("longrun Task Done");
return 1;
}

댓글 없음:

댓글 쓰기