using System.Threading.Tasks;
public static void Main()
Console.WriteLine("Hello World");
Program myProgram = new Program();
var temp = myProgram.pointlessFuncMethod(async () => await myProgram.GetById(1)).Result;
Console.WriteLine("No Exception thrown");
private async Task<MyEntity> pointlessFuncMethod<MyEntity>(Func<Task<MyEntity>> func)
var results = await func.Invoke();
}catch(NullReferenceException ne)
string temp = ne.Message;
Console.WriteLine("Exception thrown");
internal Task<MyEntity> GetById(int Id) {
MyEntity entity = new MyEntity();
return Task.FromResult(entity);
public int Id {get;set; }