Einzelnen Beitrag anzeigen

FaNIX

Registriert seit: 8. Okt 2007
36 Beiträge
 
#3

Re: Restarting Main Application in TThread Class

  Alt 1. Feb 2008, 18:29
Zitat von Muetze1:
I do not understand how this should work, because the TThread descendant belongs to your process and if application is terminated, then the process ends (and there also the thread belonging to this process, so also your thread).

And your thread runs in the same memory space as your process (better: your main VCL thread). So you can access that memory, but you have to synchronize reentrant acces due these two threads. And your statement about the application instance is not correct: on start of your process (VCL App), the application instance is created and can be referenced by the global application variable. This application instance then splits the VCL thread containing the message loop. Your thread also runs in this process and the synchronize method of TThread instances just sending a message to the message loop of VCL main thread containing an address to call from the VCL thread. Thats all about synchronizing. So, since the application variable is global, there is only one instance and so its the same as your thread can access.
Thank your for your feedback, back some code will help more
  Mit Zitat antworten Zitat