“Step over” when debugging multithreaded programs in Visual Studio

前端 未结 6 1679
青春惊慌失措
青春惊慌失措 2020-12-01 04:46

One thing that annoys me when debugging programs in Visual Studio (2005 in my case) is that when I use \"step over\" (by pressing F10) to execute to the next line

6条回答
  •  渐次进展
    2020-12-01 05:14

    I recently had the same problem of debugging only a certain thread. While I won't discount the above answer as very comprehensive and valuable (and wish I had found it 2 days ago) - I implemented the following to help "everyday" troubleshooting.

    This idea is only a simple workaround when running multiple instances of the same class in multiple threads - which our application is doing at all times.

    We initialize all class instances with a unique ID or Name, so we know how or why the instance was created. Then, when we need to debug a specific instance (i.e. thread) - and not freeze other threads, we add the following:

    if (instance.ID == myID)
    {
        // Assert BreakPoint
    }
    

    In our case, we establish fixed ID's, so we know the ID we want to troubleshoot when we have an issue.

提交回复
热议问题