I am wondering what is the best way to monitor a variable in C#. This is not for debugging. I basically want the program it self to monitor one of its variable all the time during running. For example. I am trying to watch if _a is less then 0; if it is, then the program stops.
_a = _b - _c; // (_b >= _c)
So _a ranges within [0 N], where N is some positive int; I feel the best is to start a thread that monitors the _a value. Once it, then I should response. But I have no idea how to implement it. Any one has any suggestions? A short piece of code sample will be highly appreciated.