Hello
In my script I'm using OnExit, Quit to call my Quit subroutine which then eventually calls ExitApp.
My concern is that Quit might interrupt some other thread that was doing something important like writing a file, and interrupted it half way through, leaving those files in an inconsistent state.
How can I avoid this possibility? i.e allow all interrupted threads on the stack to finish, then ExitApp.
Thanks
How to exit script gracefully Topic is solved
- AlphaBravo
- Posts: 586
- Joined: 29 Sep 2013, 22:59
Re: How to exit script gracefully
look at Critical, maybe!
Re: How to exit script gracefully Topic is solved
Regardless of whether there's an OnExit subroutine, the user can generally exit the script while a critical thread is running. However, aside from forcibly terminating the process (which you just can't stop), that requires the process to be responding to messages, such as the message sent when a user right clicks the tray icon. That doesn't happen while in the middle of an I/O operation, but it could happen (for instance) in between two calls to File.Write(). Using Critical to increase the message check frequency (e.g. Critical 10000) would make it less likely.A critical thread will be interrupted in emergencies. Emergencies consist of: 1) the OnExit subroutine; [...]
If you override the WM_COMMAND (0x111) message when wParam is ID_FILE_EXIT (65405) or ID_TRAY_EXIT (65307), you can make the Exit Script menu options do whatever you want. However, there are still other ways to exit the script, such as Reload, starting a new instance of a #SingleInstance script, or logging off the computer.
Who is online
Users browsing this forum: -Elaphe-, downstairs, sebalotek and 197 guests