Is there a way to better visualize tasks and async code flow?įor a graphical depiction of async code’s execution, Visual Studio has the Parallel Stacks window for threads and tasks. To learn more about this new feature, check out Andy Sterland’s blog post. With this update, the Exception Helper displays the original call stack when an exception is rethrown. To fix this, we’ve implemented rethrown exceptions in 16.4. Unfortunately, this isn’t always helpful for async debugging. When an exception is thrown multiple times, Visual Studio typically returns the call stack where the exception was most recently thrown via the Exception Helper. How can I locate the origin of a thrown exception in my async code?ĭetermining a thrown exception’s original location is frustrating when debugging async code. You can access the Tasks window at Debug > Windows > Task or by using CTRL+SHIFT+D, K. This can help to identify specific threads which may also be contributing to an issue. If your program is multithreaded, this window will also display the threads running each task. Good news, there’s also equivalent window for tasks! The Tasks window allows you to view all your tasks, displaying their IDs, current locations, the method originally passed into each of them, and their current statuses (active, scheduled, blocked, or deadlocked) at break time. If you’ve debugged multithreaded applications, you may be familiar with the Threads window. When you encounter a bug in your async code, you probably want to identify all your Tasks and determine which of them are causing the error. Luckily, Visual Studio has several new and old features compatible with managed, native, and JavaScript to help ease your frustrations with debugging async code. However, while it can improve your program’s overall throughput, async code is still not exempt from bugs! Writing async code makes debugging more difficult when potential deadlocks, vague error messages, and finding which task(s) are causing a bug are thrown into the mix. In a recent post, we explored the basics of asynchronous code, why it’s important, and how to write it in C#.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |