Program execution delay

Hi all! I need to make time delay in my program, but I do not have much experience with time libraries. Program uses graphics, so I need it to freeze at each point of execution for about 5 seconds, so progress is nicely visible.
I made something like this, which I assume is probably all wrong :D Anyone can nudge me in right direction?

1
2
3
4
5
6
7
8
9
10
11
12
...
while(!Q.empty())
  Q.pop();
  // ---> code...
  clock_t timer,brojac;
  timer=clock();
  brojac=clock();
  timer+=50;
  while(brojac!=timer){
    brojac=clock();
  }   
}  
1
2
3
4
5
6
7
8
9
10
#include <chrono>
#include <thread>
...
while(!Q.empty())
  Q.pop();
  // ---> code...
  std::chrono::seconds duration(5);
  std::this_thread::sleep_for(duration);
  }   
}  
I'm afraid it doesn't work. It is not allowing me to include chrono and thread libraries. I get

[C++ Error] SL.cpp(14): E2209 Unable to open include file 'chrono'
[C++ Error] SL.cpp(216): E2316 'chrono' is not a member of 'std'

Same thing I get for thread.
Looks like you are using outdated compiler which doesn't support C++11. Try:
1
2
3
#include <windows.h>
...
Sleep(5000);


http://msdn.microsoft.com/en-us/library/ms686298%28VS.85%29.aspx
I think this is working. Program does go a bit funky, but I probably haven't put delay at right place.
I'm working on C++Builder 6, that might be the reason it didn't recognize chrono and tread library...
And, thank you big time :)
Last edited on
Topic archived. No new replies allowed.