Re: Notification of WIndows Shutdown.



Bob Butler wrote:
PeterD wrote:
On Sat, 5 Jan 2008 20:35:54 -0800, "Steve Gerrard"
<mynamehere@xxxxxxxxxxx> wrote:
<cut>
Small for loop, with an embedded sleep. It sleeps for about 3
minutes, then wakes up and checks the 'other' application. If the
other application is done (checks a registry entry) then it does its
thing and closes.

If you are coming out of a Sleep API call and then immediately
checking the registry and exiting then it's possible that the
queryunload message is waiting but you're quitting before it gets
processed. You might try using a DoEvents after the sleep completes
to let any pending messages be handled first.

You could also try re-architecting so that instead of a Sleep call you
use a form with a timer and do your checks when the timer fires. That
would let you be more responsive to the shutdown requests.

I think Bob is spot on here. Your app does not shut down because the form gets
closed; it shuts down when the loop determines that the other app has shut down
(or needs help).

When a user logs off, the sequence will be:
1. Other app gets the shutdown request and closes. 2. Your app comes out of
sleep, sees that the other app is closed, and shuts down. 3. When your exit code
unloads the form, it says it was unloaded by code.

I don't think your form is doing any events. When you close it from your main
loop, that will call the queryunload handler directly, but the form is not
getting anything from its message pump. As Bob said, a DoEvents at the end of
every Sleep, or using a Timer event on a form instead, will change that.



.



Relevant Pages

  • Re: Sleep API function
    ... > using Sleep ....". ... IIRC the warnings are mainly because it makes the app that is calling it ... >> to explorer while the VB app runs in the background. ... it was a background app that I didn't care would show as 'not responding' ...
    (microsoft.public.vb.winapi)
  • Re: Newbie Questions....
    ... one question at a time Bob;) ... Ensure you are deploying your app by loading Build -> Configuration Manager ... Then I go to emulator options, has the gsm bin file path, no rom image ... software.(I presume this means I don't have CF2). ...
    (microsoft.public.pocketpc.developer)
  • Re: processor time allocation
    ... When an app is doing IO it does NOT show up in the task manager as process ... simply stating that my process is not getting cpu time really doesn't give ... > perfectly fine using Sleep to obtain a near 20 Hz frequency. ... > Which is that my App is CPU starved and windows wont give my app more than ...
    (microsoft.public.vc.mfc)
  • Re: Bob on Early Show
    ... Bob plans to take his wife on vacation... ... the most undeserving of the final 9 players. ... He probably had less than a couple of hours sleep at that point. ... YOU said he was a dud due to lack of sleep. ...
    (alt.tv.survivor)
  • Re: Timing your loops
    ... Instead of taking a 'greedy' approach that uses up as much CPU time as possible unless you remember to stop it, have you considered an approach whereby you generally do nothing, but occasionally you'll render a frame? ... Providing your timer-handling code takes less than 30ms to execute, your app should go back to sleep between frames. ... After all they are running and while doing nothing are allocated all the cpu power left....mustn't be left for a rainy day after all. ...
    (microsoft.public.win32.programmer.directx.managed)