handle system request to terminate 
Author Message
 handle system request to terminate

My application updates a database with results. If my program terminates
during update, the database may contain incorrect but appearently valid
data. For this reason, I wan to intercept system requests to terminate my
application and decline to shut down while database is being updated. In
which MFC function should I handle the system request to terminate?



Tue, 04 Mar 2003 03:00:00 GMT  
 handle system request to terminate

Have you looked into transactions.

pDatabase->BeginTrans();
    open recordset
//   update the data
    Close recordset
pDatabase->CommitTrans();

If your program dies before commit trans then none of the changes will be
made. This is a preferred way of handling these situations.

cheers,
jay.


Quote:
> My application updates a database with results. If my program terminates
> during update, the database may contain incorrect but appearently valid
> data. For this reason, I wan to intercept system requests to terminate my
> application and decline to shut down while database is being updated. In
> which MFC function should I handle the system request to terminate?



Tue, 04 Mar 2003 03:00:00 GMT  
 handle system request to terminate
If you're anticipating a user closing the main window, then handle
WM_CLOSE. If you're anticipating shutdown of Windows itself, then
handle WM_QUERYENDSESSION and WM_ENDSESSION.

Quote:

>My application updates a database with results. If my program terminates
>during update, the database may contain incorrect but appearently valid
>data. For this reason, I wan to intercept system requests to terminate my
>application and decline to shut down while database is being updated. In
>which MFC function should I handle the system request to terminate?

Don Grasberger

(remove --- from address to e-mail)



Fri, 07 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. thread auto delete and waiting for thread handle to terminate

2. terminate a running exe upon system shutdown?

3. Terminating a System process !

4. Correct Way to handle Request.Params

5. Code Review Requested - Safe Array Handling in C

6. Code Review Requested - (Paranoid?) File Handling

7. Standardized Parameter Handling - Opinions Requested

8. REQUEST: Routines to handle BCD arithmetic

9. REQUEST: Standard Input and String handling routines

10. Request for literature on Error Handling

11. Request for literature on Error Handling

12. Insufficient system resources exist to complete the requested service

 

 
Powered by phpBB® Forum Software