Hello all,
I'm trying the achieve the following (using Delphi7): After logging in to my program, the user gains control, but in the background a separate thread downloads a file from the Internet to check if the current license key is blacklisted. If it is, the user receives a prompt and the program terminates.
So I've created a separate TThread class which downloads the blacklist from the Net using InternetOpenURL/InternetReadFile.
My problem is the following:
If the user quits my program before the downloading in the background finishes, the license manager thread should be terminated by the main thread.
If the thread has done its job, it should terminate automatically.
If I use FreeOnTerminate := true I can't terminate the thread from the Main thread. But otherwise, how can I make the thread free its resources after it has done its job?
My other question is:
If the license key is blacklisted, I use Synchronize to do something with certain resources of the Application's main form.
But how do I know if the user has already closed the app and the program is in FormDestroy of the main form, for example? If I Synchronize in the wrong time, it could lead to access violations...
Thanks!