static Task MyMethodAsync(string message) { using (AsyncDiagnosticStack.Enter(" My message is: " + message)) { return(MyMethodAsync(message, CancellationToken.None)); } }
private static void Main(string[] args) { try { using (AsyncDiagnosticStack.Enter("Hi")) { Test.MainAsync().Wait(); } } catch (AggregateException ex) { foreach (var exception in ((AggregateException)ex.InnerException).InnerExceptions) { Console.WriteLine(exception.ToAsyncDiagnosticString()); } } Console.ReadKey(); }