i have an exe which ftps xml order documents up to a server at 15 minute intervals, it then reads order acknowledgement xml documents and ftps them to this machine and processes them. The whole process takes 30 seconds to a minute tops, Had an order missed last night because i believe the machine was shut downand the process terminated half way through ie after the send but before the receive, is there any way of delayinig windows shutdown until my exe terminates? orsome other approach to solving this problem? problem only occurs on small 1-3 user siteswho turn their machines off before going home. thanks | | ntsmith Tuesday, January 22, 2008 10:13 AM | On the FormClosing event you do this:
Code Block
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason = CloseReason.WindowsShutDown)
e.Cancel = true;
}
This will not allow the application to close if windows is shutting down and therefore, the Windows shutdown will be cancelled.
Regards,
Fábio | | Fábio Franco Tuesday, January 22, 2008 10:32 AM | Oh, and I forgot, if you wish to resume app shutdown, use this:
Code Block const long EWX_SHUTDOWN = 1; const long EWX_REBOOT = 2; const long EWX_FORCE = 4; const long EWX_RESERVED = 0xFFFFFFFF; [System.Runtime.InteropServices.DllImport("User32.dll")]private static extern int ExitWindowsEx(long dwOptions, long dwReserved);
Then just call the ExitWindowsEx to resume windows shutdown when your operation is complete. Hope this helps, Regards, Fábio | | Fábio Franco Tuesday, January 22, 2008 11:07 AM | On the FormClosing event you do this:
Code Block
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason = CloseReason.WindowsShutDown)
e.Cancel = true;
}
This will not allow the application to close if windows is shutting down and therefore, the Windows shutdown will be cancelled.
Regards,
Fábio | | Fábio Franco Tuesday, January 22, 2008 10:32 AM | Oh, and I forgot, if you wish to resume app shutdown, use this:
Code Block const long EWX_SHUTDOWN = 1; const long EWX_REBOOT = 2; const long EWX_FORCE = 4; const long EWX_RESERVED = 0xFFFFFFFF; [System.Runtime.InteropServices.DllImport("User32.dll")]private static extern int ExitWindowsEx(long dwOptions, long dwReserved);
Then just call the ExitWindowsEx to resume windows shutdown when your operation is complete. Hope this helps, Regards, Fábio | | Fábio Franco Tuesday, January 22, 2008 11:07 AM | | | ntsmith Tuesday, January 22, 2008 11:29 AM |
|