Visual Studio Toolbox

Asynchronous Debugging in Visual Studio 2013

Download this episode

Download Video


In this episode, Robert is joined by Brad Sullivan, who shows us asynchronous debugging in Visual Studio 2013. This enhances your debugging experience in both .NET and Windows Store apps. Previously, it could be very difficult for a developer stopped at a breakpoint to know the asynchronous sequence of calls that brought them to the current location.  Now in Visual Studio 2013, the Call Stack window surfaces this information, factoring in new diagnostics information provided by the runtime. 

For more information, check out Brad's blog post.



Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • banjomatic

      I have mixed feelings about this feature.

      I feel like on the one hand, it is a misleading as each thread's call-stack can now contain frames from multiple threads. Is there any way to surface which thread a given stack frame is running on?

      On the other hand, there may be enough value added by this abstraction to allow for a little deception. At what point does the underlying machinery of message loops and thread pools start to not matter?

      I don't believe the video touched on this, but what is the scope for which the async call-stack improvements are available in C++. Do they work at the Windows thread level, or does it require the use of  PPL Tasks / ConcRT / std::async? 

    • banjomatic

      Answering my own question about C++, it seems like (on Windows 7 anyway) the feature depends at some level on concrt as it works for std::async, but not std::thread (or ::CreateThread)

      #include <future>
      int _tmain(int argc, _TCHAR* argv[])
         auto doBreak = [](){ ::DebugBreak(); };
         // [External Code] [Async Call] [External Code]
         std::async(std::launch::async, doBreak).wait();
         // [External Code] only
         return 0;


      Another note, doesn't [Async Call] kind of imply external code? It would be nice if the 3 lines collapsed down to one if "Show External Code" is unchecked.

      [External Code]
      [Async Call]            =>          [Async Call]
      [External Code]


    • banjomatic

      One more question, probably an expected limitation, but it seems like the "Async Stack" is only 1 async call deep. In other words, calling an async method from within another async method will only show the most recent async call in the call stack. When viewing the context of the "middle" thread, you can still see the first async call that brought you to that point.

      Presumably the debugger should also be able to identify similar cases where you are waiting on another thread/task and combine the upstream callstack as well

      #include <future>
      int _tmain(int argc, _TCHAR* argv[])
         auto deferredBreak = []() {
            return std::async(std::launch::async, [](){ ::DebugBreak(); });
         // First async call is not visible from Thread2
         // [External] => Thread1 =Async=> Thread2
         // But is from Thread1
         // Main Thread =Async=> Thread1 => [External]
         std::async(std::launch::async, deferredBreak).get().wait();
         // Ideal for Thread2 might be:
         // Main Thread =Async> Thread1 =Async=> Thread2
         // And for Thread1:
         // Main Thread =Async> Thread1 =Waiting=> Thread2
         return 0;

    • Human​Compiler

      Love this! Really great for C#.

      Debugging async in Windows Phone 8 is TERRIBLE! Please please please bring this to Windows Phone too!

    • brads

      Hi Banjomatic,

      Thanks for your feedback.  You are correct that you will need to use the Tasks implementation to get the benefits of this feature in C++.

      We're also looking into improving the C++ scenario when looking through multiple async calls.


      Brad Sullivan - Visual Studio Diagnostics Team

    • banjomatic

      @brads: Thanks for the update

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.