you Have 2 Ways For This in c++:
1)Using Threads
2)Using Timer
1)Thread
with using thread you can have parallel processing in one main program.
you can put your check routine in thread and when it's occured do every thing that you want
notice that when the thread routine running the main program is running too.
2)Timer
with timers
you can check state in periodical time...
when it occured jump to every where yu want.