I need to do something in my program every 10 seconds and I don't know how to do it in C++ Console Application. In C# I could just create a timer but I'm struggling here now...
sleep(); is not an option because as far as I know it makes your program inactive for X seconds, I need my app to be active and working, calculating all the time.
Please help me with this little (or big?) problem, I'm very new to C++ and learning ATM :)
So I've set up BOOST libraries and now I'm doing something like this.
boost::timer t;
while (true)
{
if (t.elapsed() > 1)
{
cout << t.elapsed() << endl;
t.restart();
}
}
Is it good enough or there should be much better way? Oh no, it's very bad, eating 25% of my CPU non-stop. :(