Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to continuously update VS2008 Watch Window (without stopping execution)?

In Adobe Director, there is a watch window that updates while my application runs. For example, if I have a game application and am watching an instance of a ball object, I can see all of its values (velocity, altitude, state variables, etc) updating in real-time as the application is running. I can also add any other object to the window and drill down into it's variables without stopping execution.

Is there a way in Visual Studio (I'm on 2008), in C#, to have the Debug > Watch window update while my application is running? In other words, I'd like to keep an eye on the different variables of a given object while the application is running, rather than freezing everything and inspect the state of things at one particular moment in time.

If this is not possible is there any way to watch the values of arbitrary objects (without hardcoding these upfront). For example, for a tank object, we'd have position, orientation, velocity, etc. Assume dozens of different types of game objects with a dozen or so values each. These values change 60 times per second.

The goal is to be able to, at runtime, choose a game object to "watch" and then drill down into it's heirarchy of variables (in the same way the watcher pane does). Again, this tool doesn't know about the objects in advance, so can't be hardcoded for specific objects.

Thanks in advance!

Adam

like image 848
Adam Kane Avatar asked Jan 26 '26 22:01

Adam Kane


2 Answers

create a breakpoint, right click it, select on hit event, and setup printing of the variable there. This works.

If there's a particular value of a variable that you want to watch for you can use a conditional breakpoint: http://msdn.microsoft.com/en-us/library/7sye83ce.aspx

And of course there's always the trusty ASSERT() macro for that as well.

If you have really complicated debugging needs you may need to write custom code in your application just for debugging. Typically that sort of thing gets wrapped inside of #ifdef _DEBUG/#endif statements so that the release builds are not affected. You can support everything from the old standby of log file debugging up to writing a custom watch window that displays the current values that you need to see.

like image 23
onedozenbagels Avatar answered Jan 29 '26 00:01

onedozenbagels



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!