Debugging Threads in the IDE

See Also

All the threads created in the current session are displayed in the Debugging window. You can open the Debugging window by choosing Window > Debugging > Debugging (Alt-Shift-9).

Changing the Current Thread

Only one thread is the current thread at any given time. By default, the current thread is the thread within the current session from which the debugger gained control. When you switch between threads to debug, the Local Variables window is automatically updated to reflect the data applicable to that thread.

To change the current thread:

Suspending and Resuming Threads

You can suspend execution of a thread if you think it is causing problems and then later resume the thread once the problem is solved. The Debugging window enables you to easily see the threads in the debugging session and identify the running and suspended threads. The icon to the left of the thread name indicates whether the thread is suspended or waiting to be resumed.

You can suspend, interrupt and resume application threads by right-clicking a thread in the Debugging window and choosing an action from the popup menu. Alternatively, you can click the Resume ( ) and Suspend ( ) buttons in the right side of the Debugging window. You can hide the Suspend and Resume buttons by clicking the Show suspend/resume table button (Show suspend/resume table ) in the Debugging window toolbar.

Editor window icons

A thread icon in the left margin of the source editor indicates that there is a suspended thread at that line. The following table describes the icons representing the thread states that appear in the source editor during a debugging session.

Icons Description
Running thread Other suspended threads
Thread suspended by breakpoint Other threads suspended by hitting a breakpoint

To switch a suspended thread to the current thread:

Multi-threaded Applications

When debugging a multi-threaded application, a step in a particular thread may be interrupted by a breakpoint encountered in some other thread. When this occurs the IDE gives you the option to switch threads. The IDE does not automatically switch the context to the new thread.

When a breakpoint in another thread is hit you are notified by a panel that appears in the Debugging window. The current thread remains the current thread until you explicitly switch it or the thread stops. At any time you can click the arrow in the panel in the Debugging window and choose a thread to switch to that thread. This enables you to continue debugging the current thread and when it is convenient you can switch to the thread that hit a breakpoint.

Viewing Source Code for a Thread

You can view the source code of a thread in the IDE's Source Editor if you think it is causing problems and want to examine it further.

To view a thread's source:

See Also
Using the Debugging Window
Creating a Watch
Using the Call Stack
Stepping Through Your Program

Legal Notices