title: C++ : How do I execute a function after several seconds?
body: <p>Firstly, I'm using VS2008 (doesn't support C++11). I can't upgrade and need to use native libraries only because it needs to be compiled on another persons' compiler which I don't have control over.</p>
  
  <p>I would like to run the code automatically after 5 seconds without having to poll how many seconds have elapsed.</p>
  
  <p>This is my incomplete code</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;iostream&gt;
  void runMeAfterFiveSeconds(){
       cout&lt;&lt;"I'm activated!"&lt;&lt;endl;
  }
  void main(){
       while(1){
            cout&lt;&lt;"hello there!"&lt;&lt;endl;
            Sleep(2000);
       }
  }
  </code></pre>
  
  <p>Example output</p>
  
  <pre><code>hello there!
  hello there! //after 2 seconds
  hello there! //after 4 seconds
  I'm activated! //after 5 seconds
  hello there! //after 6 seconds
  hello there! //after 8 seconds
  hello there! //after 10 seconds
  I'm activated! //after 10 seconds
  ...
  </code></pre>