Multithreading – aborts the entire application from a thread in Delphi
There is a major problem with my Delphi app I'm developing a software that uses external security I am using a USB device that must be connected to the user's computer to run my software If the user has any chance to delete this dongle, or starts without a dongle, the application should warn the user and stop immediately
retCode := checkSecurity(); if retCode = -1 then begin ShowMessage('Security device not found! Terminating immediately!'); Application.Terminate; end;
The main problem here is application Terminate doesn't really kill the application I have read so and elsewhere, terminate sends an elegant shutdown signal and waits for other threads, in my case, the main thread of the application to complete I really need to kill the application as mentioned, kill all threads and exit. If possible, clean up to avoid memory leakage, but if not, please follow me I am using Delphi xe2 and windows 8.1 for development
Any ideas?
Solution
You can call ExitProcess to force immediate termination Compared with halt, the OS function ExitProcess performs less cleanup