View previous topic :: View next topic |
Author |
Message |
Portis
Joined: 26 Sep 2005 Posts: 6
|
Posted: Sun Mar 11, 2007 4:45 pm Post subject: Trapping the shutdown of a DFL program after a logout? |
|
|
Hi,
I've got a DFL system tray application that's doing what it should be (talking across the network to a Java server), but I've run across something strange.
I have a 'shutdown' procedure that's called when the application is closed, and it's firing in all cases *except* when the user logs out (or shuts down probably, but I didn't test that) from the workstation.
The DFL app is just 'forced' closed on logout, which leaves the network stuff still hanging around on the server.
I've run a few tests with a much simpler system tray application, and found that neither of these methods fire when the user logs out:
- using a delegate for Application.threadExit or ApplicationContext.threadExit
- overriding onClosing
- using the Form 'closed' method
After 'googling' a bit, I've seen this same problem with a few other Win32 languages/toolkits and it seems to be related to not handling the WM_ENDSESSION message correctly (or at all).
Hunting around in the DFL source reveals WM_ENDSESSION is handled to some degree in the SessionEndingEventArgs class in the Environment.d file, but I'm a little confused about how to use it.
Is there something I'm not doing (or doing wrong) that would stop DFL from catching logout events?
I can provide the simple DFL tray test program if it'll help.
Thanks in advance. _________________ - Brendon - |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Wed Mar 14, 2007 5:32 pm Post subject: Re: Trapping the shutdown of a DFL program after a logout? |
|
|
The code in DFL that uses WM_ENDSESSION is commented out, it's a future plan.
I assume your program hangs on logoff/shutdown because you have a separate thread waiting for socket events, so Windows tries waiting for that to end gracefully, but it's not setup to do so.
What I think you can do now is add a message filter (in the main thread, via Application.addMessageFilter) that looks for WM_ENDSESSION and breaks out of the socket stuff or forcefully exits the program (e.g. Environment.exit(0)).
Sorry about the late reply.
- Chris |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|