获取正在执行的Func <task <t>&gt;的名称怎么在Portable类库中?

时间:2017-07-29 09:45:42

标签: c#

如何根据以下签名获取我正在执行的方法的名称:

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

}

期望的结果:myservice.GetCustomer

我尝试过如下,但它不起作用。理想情况下,我想在没有反思的情况下这样做

string methodName = taskToExecute.GetMethodInfo().Name;

0 个答案:

没有答案