Partilhar via


How to: Specify a Hit Count 

This topic applies to:

Visual Studio Edition

Visual Basic

C#

C++

J#

Web Dev

Express

No

No

Yes

No

No

Standard

Yes

Yes

Yes

Yes

Yes

Pro/Team

Yes

Yes

Yes

Yes

Yes

Hit count keeps track of how many times a breakpoint is hit.

By default, execution breaks every time a breakpoint is hit. You can choose to:

  • Break always (the default).

  • Break when the hit count equals a specified value.

  • Break when the hit count equals a multiple of a specified value.

  • Break when the hit count is greater or equal to a specified value.

If you want to keep track of the number of times a breakpoint is hit but never break execution, you can set the hit count to a very high value so that the breakpoint is never hit.

The specified hit count is retained only for the debugging session. When the debugging session ends, the hit count is reset to zero.

To specify a hit count

  1. In the Breakpoints window, right-click on a breakpoint and choose Hit Count from the shortcut menu

    —or—

    In a source, Disassembly, or Call Stack window, right-click on a line containing a breakpoint and choose Hit Count from the Breakpoints submenu in the shortcut menu.

  2. In the Hit Count dialog box, choose the behavior you want from When the breakpoint is hit list box.

  3. If you choose any setting other than break always, an edit box appears next to the list box. Edit the integer that appears in the edit box to set the hit count you want.

  4. Click OK.

See Also

Tasks

How to: Specify a Breakpoint Condition

Concepts

Breakpoints and Tracepoints