0. Test program
The program above simply prints out a random number in a loop until the number generated is equal to 1.
1. Setting Conditions
You can set conditions on when to pause the program execution. Right-click on the breakpoint circle and you will see the context menu containing several options;
If you click on the Condition, you will be prompted with a dialog window in which you can enter a boolean expression. As an example, let's insert a breakpoint at the line Console.WriteLine(...) and set the condition as;
Hit count setting takes into account the number of times the breakpoint is being "hit". It is basically setting a condition on the hit count, pausing when the count is either equal to a number, a multiple of a number, or greater than or equal to a number. This setting can also be changed during debugging, where you can see the current hit count and set a new condition as you wish.
i == 1Now if you run the program in debugging mode, it will start printing random numbers until the generated number becomes equal to 1 and pauses at the breakpoint.If the condition is not met, the breakpoint will be ignored.
2. Hit Count
3. Filter
You can also set the filter to break for certain processes or threads if you are running multi-threaded program. if your thread Id is 111, then setting;
ThreadId = 111
on the dialog window for Filter will make the thread pause at the breakpoint, but other threads will ignore it.
No comments:
Post a Comment