How do I get the name of the method I am executing given the following signature:
MyMethodAsync( ()=> myservice.GetCustomer)
public async Task MyMethodAsync(Func<Task> taskToExecute)
{
//Get the name of the task that is executing
// eg "myservice.GetCustomer
taskToExecute.??
}
public async Task MyMethodAsync<T>(Func<Task<T>> taskToExecute)
{
//Get the name of the task that is executing eg
// "myservice.GetCustomer
}
Desired result: myservice.GetCustomer
I have tried as follows, but it does not work. Ideally I'd like to do it without reflection
string methodName = taskToExecute.GetMethodInfo().Name;