Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to delay shutdown of an application when user logs off or shuts down Windows?
    primarykey
    data
    text
    <p>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.</p> <p>While I have certainly done some research on the topic, the information regarding the way that windows handles application shut down (<a href="http://msdn.microsoft.com/en-us/library/ms700677(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms700677(VS.85).aspx</a>) 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#).</p> <p>Thanks!!</p> <p>badPanda</p> <p>Edit: I am aware that blocking shutdown is not considered to be good practice. It is a critical business requirement for this application.</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload