title: Get current method name from async function?
body: <p>Is there anyway to get the current method name from inside an async function?</p>
  
  <p>I've tried:</p>
  
  <pre><code>System.Reflection.MethodInfo.GetCurrentMethod();
  </code></pre>
  
  <p>And I've tried using StackTrace and StrackFrame as follows:</p>
  
  <pre><code>StackTrace strackTrace = new StackTrace();
  
  for (int i = 0; i &lt; strackTrace.GetFrames().Length; i++)
  {
      SafeNativeMethods.EtwTraceInfo("Function" + i + ":" + function);
      SafeNativeMethods.EtwTraceInfo("Type" + i + ":" + strackTrace.GetFrame(i).GetType().Name);
      SafeNativeMethods.EtwTraceInfo("Method" + i + ":" + strackTrace.GetFrame(i).GetMethod().Name);
      SafeNativeMethods.EtwTraceInfo("ToString Call" + i + ":" + strackTrace.GetFrame(i).ToString());
  }
  </code></pre>
  
  <p>But neither of them seem to work, I'd get ".ctor", "InvokeMethod", "Invoke", "CreateInstance", "CreateKnownObject" or "CreateUnknownObject" or "MoveNext"</p>
  
  <p>Any ideas on how I can do this?  I want to create a generic logger function and I don't want to pass in the name of the function that called the logger function, so I tried the stacktrace method, didn't work.</p>
  
  <p>I gave up on that and said, ok, I'll pass in the function name as the first parameter, but when I called the reflection method from the calling function that calls the generic logger function, I always get ".ctor"</p>
  
  <p>Any ideas?  Note the generic logger function I'm calling is a static method in the same class (it has to be this way for now...).</p>