0

hi guys...when we have used Sleep() function, then how can we get out of this Sleep() function....Lets suppose we have used Sleep() for 10 minutes and I want to terminate the prog after 2 mins, here is the situation im using

someFunc();
printf("\nProg will not terminate for next 5 secs");
Sleep(5000);
printf("\n\nPress any key to EXIT....");
getche();
3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by muze
0

@AncientDragon....yup, since this is console app, I was looking if there is some way to use SORT OF event driven mechanism like "Hitting the ENTER key" and getting out of Sleep()?

0

If you know your input stream is clear, you could just throw in some sort of blocking input read, like a cin.get() . That will make the program wait until some sort of input shows up on the input stream.

Edited by Fbody: n/a

0

Console programs are NOT event-driven programs.

The only way to get out of Sleep() is to create another thread that sends a signal to the os to kiill that Sleep() function. But then that is a lot more complicated than the little loop I posted :)

Edited by Ancient Dragon: n/a

0

Console programs are NOT event-driven programs

I know that, thats why I used SORT OF. Thanks anyway

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.