Einzelnen Beitrag anzeigen

Muetze1
(Gast)

n/a Beiträge
 
#2

Re: Restarting Main Application in TThread Class

  Alt 1. Feb 2008, 15:09
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.
  Mit Zitat antworten Zitat