I'm using Visual Studio 2012 and C++, I need to call a function every 5 minutes, I've managed to do it but it consumes 25% of my CPU which is far from ideal.
The code is as follows,
time_t start;
time_t end;
time(&start);
while (1) {
time(&end);
double dif = difftime (end,start);
if (dif >= 300) { autofunction(); time(&start);} else {} }
Is there a more CPU efficient way to go about calling a function every 5 minutes or any way to slow down my while loop?
Any guidance will be greatly appreciated.