VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Let your application close orderly before the system reboot. Avoid hanging the O/S while your appli

by Jack van Niekerk (2 Submissions)
Category: Windows System Services
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Thu 25th January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Let your application close orderly before the system reboot. Avoid hanging the O/S while your application is running and the user want's to

Rate Let your application close orderly before the system reboot. Avoid hanging the O/S while your appli




If you don't shutdown properly your application may not release system resources and the O/S will not shutdown. Users will have to use Ctrl-Alt-Del to zap your application.

Method 1: Create a sub class that will monitor the system level messages from the O/S. Trap the shutdown message and close all database connections and open file handles. I.O.W. do a proper app close and exit. If you have worked with sub-classes you will know this is a very very big pain in a place you do not want pain.

Method 2: The simple but effective method. Create hidden form, which will be your startup object. In the load event of this form you call Sub Main(). In the unload or terminate event (you pic one) of this form you call a shutdown procedure that will orderly close all connections, open file handles etc etc. The O/S sends a shutdown message to the application's main form when it is about to reboot, which will trigger the form's unload/temrinate events. The few milliseconds between that and the actual attempted zapping of your application by the O/S is enough time to orderly close everything.

The NT shutdown command will in fact give a 30second grace period after the message before it will zap the application. Windows 9X will wait indefinately if it cannot close your application.


Download this snippet    Add to My Saved Code

Let your application close orderly before the system reboot. Avoid hanging the O/S while your appli Comments

No comments have been posted about Let your application close orderly before the system reboot. Avoid hanging the O/S while your appli. Why not be the first to post a comment about Let your application close orderly before the system reboot. Avoid hanging the O/S while your appli.

Post your comment

Subject:
Message:
0/1000 characters