I am writing an application that runs in the background from startup to shutdown, and in some circumstances I need the application to display a dialogue for the user to choose whether or not to continue shutting down. This application will only be running on Windows, but may be running on any version from 2000 onward.
While I have certainly done some research on the topic, the information regarding the way that windows handles application shut down (http://msdn.microsoft.com/en-us/library/ms700677(VS.85).aspx) seems to be a bit scattered. If anyone has an example of the best way to handle this, or additional knowledge regarding the topic, I would very much appreciate it (I have very little experience with C#).
Thanks!!
badPanda
Edit: I am aware that blocking shutdown is not considered to be good practice. It is a critical business requirement for this application.
Edit: On suggestion of the several commentators below (to redesign so that blocking shutdown is unnecessary), I have utilized a NotifyIcon Balloon popup to inform users not to shut down when the application is sending data. While this is not AS likely to prevent data from being held up on a local computer for weeks, I feel that it is a good compromise between the best practice and the business requirements. After all, if users will be stupid...well, users will be stupid.