using System.Threading.Tasks;
using System.Diagnostics;
static async Task Main(string[] args)
Console.WriteLine("Calling async function without await:");
CallAsyncFunctionWithoutAwait();
Console.WriteLine("\nCalling async function with await:");
await CallAsyncFunctionWithAwait();
Console.WriteLine("Main method completed.");
public static async Task<int> GetDataAsync()
Console.WriteLine("Async function completed.");
public static void CallAsyncFunctionWithoutAwait()
var stopwatch = new Stopwatch();
var result = GetDataAsync();
Console.WriteLine($"Function called, but not awaited. completed in {stopwatch.ElapsedMilliseconds}");
stopwatch = new Stopwatch();
var result2 = result.Result;
Console.WriteLine($"getting result. {result2}, Completed in {stopwatch.ElapsedMilliseconds}");
public static async Task CallAsyncFunctionWithAwait()
var result = await GetDataAsync();
Console.WriteLine($"Function awaited, result: {result}");