I am trying to make a C++ timer on windows which has following functionality:
Once the function is called, timer should start and last for 10 seconds, but in this period of time, it shouldn’t block other functions working.
I mean if timer should run in background and if it reaches to 10, a special function should be called and timer value should be reset.
If timer doesn’t reach to 10 and gets call for the second time, it should be reset to zero and start again.
Expand|Select|Wrap|Line Numbers
- Counter=0;
- Void function()
- {
- if (counter == 0)
- time (&start);
- ::counter++;
- for ( ; ; )
- {
- if (elapsed_time = difftime(time( &finish ), start )>10)
- {
- cout << "Time out Has Occurd" << endl;
- time( &start );
- }
- }
- }
Is there any other command that can help me?