title: Building a 'shadow stack' across threads when profiling the CLR
body: <p>I am building a profiler, and am trying to replicate the call stack of the application being profiled.</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/bb384634(v=vs.90).aspx" rel="nofollow noreferrer">This article</a> on profiling the CLR recommends building a 'shadow' stack using the  Enter/Leave method callbacks (<code>SetEnterLeaveFunctionHooks</code>), rather than using the snapshot method.</p>
  
  <p>Is there a way to associate these callbacks when they are part of the same call stack, but could potentially occur on different threads? (for example, when the application being profiled uses <code>Task.Run</code> or <code>async/await</code>). </p>
  
  <p>Ideally, I would like to show the user a call stack that 'follows' async methods, so associating them by <code>ThreadId</code> is unreliable.</p>