I'm trying to write a function that puts the amount of time in seconds the program has been running into a global variable. I've got one, but it eats CPU time like crazy.
curTime = 0;
CreateThread(0, 0, TimeHandler, NULL, 0, &nThreadID);
DWORD WINAPI TimeHandler(void* a)
firstTime = time(NULL);
curTime = time(NULL) - firstTime;
curTime is a global variable.
There must be a better way to do this. Any suggestions on how to decrease the amount of CPU time this takes, or maybe a totally different approach all together?