0

Hi,

I'm updating an IM client C app (for Windows XP) so that when a users screensaver comes on their presence state changes from online to away.
What I've done so far is add:

while(TRUE){
        refreshAutoAway();
        Sleep(1000);
    }

to the end of the WinMain function.
This all does what I want until I exit the application, when the process remains running in windows task manager. If I remove this code the application closes cleanly.
So got a couple of queries - firstly, am I going about this in the 'right' way (ie is using sleep() the best thing to do in this case)? and secondly, how I can ensure my repeated call to the function closes correctly when the app is exited?
Just let me know if you need to see any more bits of the code.
Cheers & TIA,
Alex
ps. the last time I did anything with C was about 8 years ago at college - so please consider me a newbie! ;-)

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by Ancient Dragon
0

since this is a normal windows program you could replace sleep with a timer (see SetTimer() in MSDN) that is triggered every xxx milliseconds, and move call to refreshAutoAway() inside the timer event handler. Then replace that loop with the message pump, calling PeekMessage(), which will block your program until a windows message is received.

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.