View Single Post
  #1   Spotlight this post!  
Unread 01-02-2008, 12:30
FaNIX FaNIX is offline
Registered User
no team
 
Join Date: Feb 2008
Location: sa
Posts: 1
FaNIX is an unknown quantity at this point
Restarting Main Application in TThread Class

Hi People,

I am trying to restart my Main Application by using code inside a Thread. Basicly my restart function works 100% when placed inside the Main Application code. But since a TThread runs in another memory space, i think reference to the Application.Terminate is not set to the Main Application, maybe to the thread, I don't know.

Here is my restart procedure inside my Thread:

Quote:
procedure TUpdateLibThread.AppRestart;
var
HANDLE : HWND;
begin
ShellExecute(HANDLE,'open',Application.ExeName, '', '', 1) ;
Application.Terminate;
end;
The thread is called by die main application, but the restart application must be inside the thread, as the outcome of the thread determines if the application should be restarted or not. If there is a way to return a value back to the main application when the thread ends, then i might be able to use that to determine if i need to call the restart procedure...

Help?