From: Rick Raisley on
I'm trying to have my app log status on a process that can take a long time.
Another app will read that status, and act accordingly. I can log (to a
file) when the first app starts, and when it completes. The problem is, if
Windows exits before the first app can complete its job, the completion log
will not be written. The next time Windows starts, the second app will then
read the file, and cannot tell if the first app has started but is not yet
done, or if it ended, due to Windows shutting down, and is no longer
running.

I guess I could check to see if the first app is running (might even be the
best way). But I was thinking of a simpler way, IF the Form_Unload event
runs in my app when Windows shuts down. If it does, I can, using the Escape
value, write a log file that indicates the app's operation was not complete.
Or even delete the log entry that the app has started. In any event, if
Form_Unload fires on Windows shutdown, I can log that the operation was not
complete, and needs to be restarted.

So, does anyone know if Form_Unload and/or Form_QueryUnload fire when
Windows shuts down the programs? I kind of assume it will (unless the PC is
just powered down), but don't know (without making an app and testing, at
least).

--
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net


From: Bob Butler on

"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
news:uvzRYoZ7IHA.4112(a)TK2MSFTNGP05.phx.gbl...
<cut>
> So, does anyone know if Form_Unload and/or Form_QueryUnload fire when
> Windows shuts down the programs? I kind of assume it will (unless the PC
> is just powered down), but don't know (without making an app and testing,
> at least).

The events do run, as a quick test would have shown, but users could still
terminate your app or a system crash could stop it early or.... it'd
probably be better to make a log entry somewhere on completion (or even
build the file under a temporary name and then rename it as the last step).

From: Rick Raisley on
"Bob Butler" <noway(a)nospam.ever> wrote in message
news:ueg8CrZ7IHA.616(a)TK2MSFTNGP02.phx.gbl...
>
> "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
> news:uvzRYoZ7IHA.4112(a)TK2MSFTNGP05.phx.gbl...
> <cut>
>> So, does anyone know if Form_Unload and/or Form_QueryUnload fire when
>> Windows shuts down the programs? I kind of assume it will (unless the PC
>> is just powered down), but don't know (without making an app and testing,
>> at least).
>
> The events do run, as a quick test would have shown, but users could still
> terminate your app or a system crash could stop it early or.... it'd
> probably be better to make a log entry somewhere on completion (or even
> build the file under a temporary name and then rename it as the last
> step).
>

I'm actually already doing that. But I have to determine, from another
program, whether it is still running, but has not yet finished, or if it was
ended before completion. The log entry works fine to tell the other app it
has completed its task. But if the log entry is not there, did is the app
still running and hasn't finished yet, or was it interrupted by a shutdown
before it was complete? Using the Query_Unload event, if it fires on Windows
shutdown, I can do that. If it doesn't fire, then it's tougher.

--
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net


From: expvb on
"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
news:%23AQVSEa7IHA.1468(a)TK2MSFTNGP05.phx.gbl...
> I'm actually already doing that. But I have to determine, from another
> program, whether it is still running, but has not yet finished, or if it
> was ended before completion. The log entry works fine to tell the other
> app it has completed its task. But if the log entry is not there, did is
> the app still running and hasn't finished yet, or was it interrupted by a
> shutdown before it was complete? Using the Query_Unload event, if it fires
> on Windows shutdown, I can do that. If it doesn't fire, then it's tougher.

Query/Unload always fire unless someone ended the process.from Task Manager
or similar tools. However, in a terminal services session, I noticed that
MsgBoxes are not shown at Unload event when the session is logged off. It
seems under a terminal services session(Windows 2000) that MessageBox fails
and so you get the impression that Unload events are not called if the
message box is the only means by which you tell if the event happened or
not. You can try this with Notepad, type some text, then log the session
off. You will notice that the save as prompt didn't show up and Notepad
disappeared from the screen. So use other methods to tell if the event
fired, especially under Terminal Services or fast user switching.


From: kpg on
> I'm actually already doing that. But I have to determine, from another
> program, whether it is still running, but has not yet finished, or if
> it was ended before completion. The log entry works fine to tell the
> other app it has completed its task. But if the log entry is not
> there, did is the app still running and hasn't finished yet, or was it
> interrupted by a shutdown before it was complete? Using the
> Query_Unload event, if it fires on Windows shutdown, I can do that. If
> it doesn't fire, then it's tougher.

You could (over)write a timestamp to a file every so often (60 seconds)
and if the time stamp is old you can assume the program is no longer
running.
 |  Next  |  Last
Pages: 1 2
Prev: Indicator to Run One Time
Next: Help on F1