I have an async method and I want to get a message from the same method when it gets done.
Below is the code
static async Task<string> pizza()
{
await Task.Delay(10);
for (int i = 0; i < 100; i++)
{
//Console.WriteLine("Processing pizza...");
}
return "Pizza is ready";
}
And I want to get receive this message at calling point
....... code
Task t=null;
switch (option)
{
case 1:
{
await Task.Run(() =>
{
t=pizza();// asynchronous method
});
Console.WriteLine(t.ToString());
}
break;
.... other code
await