{
static void Main(string[] args)
{
var test = new AsyncTest();
//√3Λදࣔ͢Δɻ
//ResultϓϩύςΟʹΑΓॲཧऴྃ࣌·ͰϝΠϯεϨουऴྃ͠ͳ͍
Console.WriteLine(test.SumTwoAndSqrt(1.0, 2.0).Result);
}
}
class AsyncTest
{
//2ͭͷҾΛͯ͠ฏํࠜΛऔΔϝιουɻ
//Sqrt͕return͢Δͷdoubleܕ͔ͩɺasyncम০ʹΑΓTask<double>ܕʹม͞ΕΔ
public async Task<double> SumTwoAndSqrt(double num1, double num2)
{
//ຊདྷͳΒRunTask<double>Λฦ͕͢
//awaitम০ʹΑΓ݁ՌͷdoubleܕมͷΈ͕நग़͞Εͨ
double result = await Task.Run(() => num1 + num2);
return Math.Sqrt(result);//લͷॲཧ݁ՌresultΛ༰қʹ͑Δ
}
}