Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 92927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:15:51+00:00 2026-05-10T23:15:51+00:00

One thing that annoys me when debugging programs in Visual Studio (2005 in my

  • 0

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 of code, I often end up reaching that particular line of code in a totally different thread than the one I was looking at. This means that all the context of what I was doing was lost.

How do I work around this?

If this is possible to do in later versions of Visual Studio, I’d like to hear about it as well.

Setting a breakpoint on the next line of code which has a conditional to only break for this thread is not the answer I’m looking for since it is way too much work to be useful for me 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:15:51+00:00Added an answer on May 10, 2026 at 11:15 pm

    I think there is only one answer to your question, which you have discounted as being ‘way too much work.’ However, I believe that is because you are going about it the wrong way. Let me present steps for adding a conditional breakpoint on Thread ID, which are extremely easy, but not obvious until you know them.

    1. Stop the debugger at a point where you are in the correct thread you want to continue debugging in (which I would guess is usually the first thread that gets there).

    2. Enter $TID into the watch window.

    3. Add a break point with the condition $TID == <value of $TID from Watch Window>,
      Example: $TID == 0x000016a0

    4. Continue Execution.

    $TID is a magic variable for Microsoft compilers (since at least Visual Studio 2003) that has the value of the current Thread ID. It makes it much easier than looking at (FS+0x18)[0x24]. =D

    That being said, you can get the same behavior as the debugger’s One-Shot breakpoints with some simple macros. When you step over, the debugger, behind the scenes, sets a breakpoint, runs to that breakpoint and then removes it. The key to a consistent user interface is removing those breakpoints if ANY breakpoint is hit.

    The following two macros provide Step Over and Run To Cursor for the current thread. This is accomplished in the same manner as the debugger, with the breakpoints being removed after execution, regardless of which breakpoint is hit.

    You will want to assign a key combination to run them.

    NOTE: One caveat — The Step Over macro only works correctly if the cursor is on the line you want to step over. This is because it determines the current location by the cursor location, and simply adds one to the line number. You may be able to replace the location calculation with information on the current execution point, though I was unable to locate that information from the Macro IDE.

    Here they are and good luck bug hunting!!

    To use these macros in Visual Studio:
    1. Open the Macro IDE ( from the Menu, select: Tools->Macros->Macro IDE… )
    2. Add a new Code File ( from the Menu: select: Project->Add New Item…, choose Code File, and click Add )
    3. Paste in this code.
    4. Save the file.

    To add key combinations for running these macros in Visual Studio:
    1. Open Options (from the Menu, select: Tools->Options )
    2. Expand to Environment->Keyboard
    3. In Show commands containing:, type Macros. to see all your macros.
    4. Select a macro, then click in Press shortcut keys:
    5. Type the combo you want to use (backspace deletes typed combos)
    6. click Assign to set your shortcut to run the selected macro.

    Imports System Imports EnvDTE Imports EnvDTE80 Imports System.Diagnostics  Public Module DebugHelperFunctions      Sub RunToCursorInMyThread()         Dim textSelection As EnvDTE.TextSelection         Dim myThread As EnvDTE.Thread         Dim bp As EnvDTE.Breakpoint         Dim bps As EnvDTE.Breakpoints          ' For Breakpoints.Add()         Dim FileName As String         Dim LineNumber As Integer         Dim ThreadID As String          ' Get local references for ease of use          myThread = DTE.Debugger.CurrentThread         textSelection = DTE.ActiveDocument.Selection          LineNumber = textSelection.ActivePoint.Line         FileName = textSelection.DTE.ActiveDocument.FullName         ThreadID = myThread.ID          ' Add a 'One-Shot' Breakpoint in current file on current line for current thread         bps = DTE.Debugger.Breakpoints.Add('', FileName, LineNumber, 1, '$TID == ' & ThreadID)          ' Run to the next stop         DTE.Debugger.Go(True)          ' Remove our 'One-Shot' Breakpoint         For Each bp In bps             bp.Delete()         Next     End Sub      Sub StepOverInMyThread()         Dim textSelection As EnvDTE.TextSelection         Dim myThread As EnvDTE.Thread         Dim bp As EnvDTE.Breakpoint         Dim bps As EnvDTE.Breakpoints          ' For Breakpoints.Add()         Dim FileName As String         Dim LineNumber As Integer         Dim ThreadID As String          ' Get local references for ease of use          myThread = DTE.Debugger.CurrentThread         textSelection = DTE.ActiveDocument.Selection          LineNumber = textSelection.ActivePoint.Line         FileName = textSelection.DTE.ActiveDocument.FullName         ThreadID = myThread.ID         LineNumber = LineNumber + 1          ' Add a 'One-Shot' Breakpoint in current file on current line for current thread         bps = DTE.Debugger.Breakpoints.Add('', FileName, LineNumber, 1, '$TID == ' & ThreadID)          ' Run to the next stop         DTE.Debugger.Go(True)          ' Remove our 'One-Shot' Breakpoint         For Each bp In bps             bp.Delete()         Next     End Sub   End Module 

    Disclaimer: I wrote these macros in Visual Studio 2005. You can probably use them fine in Visual Studio 2008. They may require modification for Visual Studio 2003 and before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 144k
  • Answers 144k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer if you dont want to use vector try this... MyColor(uint8… May 12, 2026 at 8:41 am
  • Editorial Team
    Editorial Team added an answer You can plot in Google Earth by creating a special… May 12, 2026 at 8:41 am
  • Editorial Team
    Editorial Team added an answer Calling it a legacy technology is a more accurate description.… May 12, 2026 at 8:41 am

Related Questions

Just a thing that annoys me. When I right click on a method name
I spend a lot of my time in emacs, and for the most part
One thing really really annoys me about the Eclipse ide : its find UI
One of the things I like most about Cocoa is the readability factor. One

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.