RaelB 4 Posted December 30, 2020 I have a VCL app, running on Windows 10, Delphi 10.3.2. Sometimes when I press the X button on the main form (to exit the app), the application does not close. The Main window disappears, however the IDE continues in "Running mode" / Debug Mode, i.e. the Program Reset button continues to be Red. When I press the Red button, the program then terminates completely and normally. Not too much going on in the application. What could be causing the program execution to hang in this way? How can I go about trying to figure out the cause? (I have no OnClose or OnCloseQuery handlers) Thanks Rael Share this post Link to post
FPiette 383 Posted December 30, 2020 You may have hidden some exception (Empty except block in a try/except). You may have a thread still running. You may have an issue in a finalization section of any unit. And many others. Did you tried running under the debugger? Share this post Link to post
Anders Melander 1783 Posted December 30, 2020 Instead of terminating the application in the debugger you can pause it and then examine the call stack to see what the application was doing. Share this post Link to post
Der schöne Günther 316 Posted December 30, 2020 1 hour ago, FPiette said: You may have a thread still running. Not necessarily a thread (the application will close anyway), but a task: procedure TForm1.Button1Click(Sender: TObject); begin TThread.CreateAnonymousThread( procedure() begin while true do; end ).Start(); end; procedure TForm1.Button2Click(Sender: TObject); begin TTask.Run( procedure() begin while true do; end ); end; The application will close fine after Button1 has been clicked. The executable, however, will never terminate after closing the main form if Button2 was pressed. Share this post Link to post
Lajos Juhász 293 Posted December 30, 2020 It also can be that the application is generating a memory leak log when ReportMemoryLeaksOnShutdown := True it can take longer whene there is an extended leak to report. Share this post Link to post
RaelB 4 Posted December 30, 2020 Thanks alot for the suggestions, especially Der schöne Günther - It is indeed related to a TTask not completing. Since the nature of the problem relates more to TTask I am going to follow up the issue over here: https://en.delphipraxis.net/topic/4174-ttask-running-twice/ Share this post Link to post