Hussain Murtaza
Hussain Murtaza

Reputation: 139

Feature of VS 2010

Is there a feature in VS 2010 that allows me to look at the value of a variable when it changes. Like suppose I have a data type bool and its value is false and when its value changes to true I get into debugging mode or Another scenario is that I have a data type int and when its value changes I get into debugging mode.

The main reason I am asking this question is because I want to check value in my XNA game in Update method, and as Update method execute 60 time/sec so its kinda hard to do it in debugging mode.

Upvotes: 3

Views: 50

Answers (1)

rene
rene

Reputation: 42414

You can set a condition on the Breakpoint

[Right-Click the Breakpoint] -> Condition

In the condition field you can either type a simple variable and have the breakpoint hit if it's value change or you can enter a boolean expression that breaks in to debug mode if that expression is true.

It comes in handy in iterations, but also comes with a performance penalty. I'm not an XNA guy so you might be better off implementing some Debug support that does the conditional check, maybe guarded with a DEBUG conditional check:

int value = 0;
// some stuff changing value
#if DEBUG
   if (value == 42)
   {
         Debug.WriteLine(value); // set a breakpoint on this line
   }

#endif

Condensed based on this blog Msdn VS2010 Tips and Tricks that also comes with screenshots.

Upvotes: 1

Related Questions