How do I create a timer? (Do something every X seconds/minutes/hours)
<p>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...</p>

<p>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.</p>

<p>Please help me with this little (or big?) problem, I'm very new to C++ and learning ATM :)</p>

<p>So I've set up BOOST libraries and now I'm doing something like this.</p>

<pre><code>boost::timer t;

while (true)
{
    if (t.elapsed() &gt; 1)
    {
        cout &lt;&lt; t.elapsed() &lt;&lt; endl;
        t.restart();
    }
}
</code></pre>

<p>Is it good enough or there should be much better way? Oh no, it's very bad, eating 25% of my CPU non-stop. :(</p>
