using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Async_and_Await___Simple
{
class Program
{
static void Main(string[] args)
{
//async and await are nothing but Code Markers which mark code positions from where control should resume after a taks(thread) completes.
//What are Async and Await ( .NET 4.5 Interview question with answers)?
//https://www.youtube.com/watch?v=V2sMXJnDEjM
Console.WriteLine("BEFORE");
Method();
Console.WriteLine("AFTER");
Console.ReadKey();
}
private static async void Method() //method must be async (which contains an await marker at least)
{
//put a debug point here > start debugging > press f11 again and again
await Task.Run(new Action(LongTask));
Console.WriteLine("New Thread");
}
public static void LongTask()
{
Thread.Sleep(15000);
}
}
}