async/await , Task.ContinueWith.ContinueWith.ContinueWith ..
, Task.ContinueWith, , .
, ,
public static void Main()
{
Launch();
}
public static async void Launch()
{
Console.WriteLine("Hello!! welcome to task application");
Console.ReadKey();
Console.WriteLine(await GetMessage());
Console.ReadKey();
}
public static Task<string> GetMessage()
{
return Task.Factory.StartNew<string>(() =>
{
return "Good Job";
});
}
:
public static void Main()
{
Launch();
}
public static async void Launch()
{
Console.WriteLine("Hello!! welcome to task application");
Console.ReadKey();
return Task.Factory.StartNew(() => GetMessage())
.ContinueWith((t) =>
{
Console.WriteLine(t.Result)
Console.ReadKey();
});
}
public static Task<string> GetMessage()
{
return Task.Factory.StartNew<string>(() =>
{
return "Good Job";
});
}
, GetMessage() ContinueWith, . , .
, :
Launch().Wait();
ContinueWith() , , , , "" .
, , await, TPL , .
, , . async/await /ContinueWith.
async/ TPL . .