Running operation at shutdown
-
Is there a way to run a potentially long operation at shutdown while (displaying progress and the ability to cancel to the user). Something like the synchronising folders that happens after the user has shutdown on a domain computer. I do not want to prevent shutdown or anything like that, just allow my application to finish any necessary processing as part of the shutdown process.
-
Is there a way to run a potentially long operation at shutdown while (displaying progress and the ability to cancel to the user). Something like the synchronising folders that happens after the user has shutdown on a domain computer. I do not want to prevent shutdown or anything like that, just allow my application to finish any necessary processing as part of the shutdown process.
Hi! You'll have to subscribe to the (static)
SessionEnding
event ofSystemEvents
class and perform your operation in the corresponding event handler.Regards, mav -- Black holes are the places where God divided by 0...
-
Hi! You'll have to subscribe to the (static)
SessionEnding
event ofSystemEvents
class and perform your operation in the corresponding event handler.Regards, mav -- Black holes are the places where God divided by 0...
Thanks, I have tried hooking that event and I can start the process when I receive the event but I only have a limited time (very short) to respond before Windows displays a dialog saying the aplpication has not closed (the one with the progress ticking down and "End Now" button), this would not be acceptable. I was hoping there was a way to run a long operation after the user session has ended but before the machine has shut down, such as the offline files synchronisation process in Windows.
-
Thanks, I have tried hooking that event and I can start the process when I receive the event but I only have a limited time (very short) to respond before Windows displays a dialog saying the aplpication has not closed (the one with the progress ticking down and "End Now" button), this would not be acceptable. I was hoping there was a way to run a long operation after the user session has ended but before the machine has shut down, such as the offline files synchronisation process in Windows.
I don't know if there's a way to tell windows to postpone shutdown (perhaps there's a registry key for this), but right now I see only 2 alternatives: 1) Cancel the shutdown while your shutdown process is still running or 2) Start the shutdown process in a separate thread and don't cancel windows shutdown. But then your shutdown process can be aborted unexpectedly, so this might not be a good idea (depending on the real use case).
Regards, mav -- Black holes are the places where God divided by 0...