For my link archive:
If you use Threads or global Objects (which are created in the
initialization
section for example) You have to cleanup/shutdown them in theOnTerminate
event of the ISAPI Application. If You destroy/shutdown them in thefinalization
section in a unit it could end up in a hanging application pool in IIS on shutdown/reuse and some windows event log entries.//added
procedure
DoTerminate;
begin
//free global objects and wait/terminate threads here
end
;
exports
GetExtensionVersion,
HttpExtensionProc,
TerminateExtension;
begin
ReportMemoryLeaksOnShutdown :=
true
;
CoInitFlags := COINIT_MULTITHREADED;
Application
.
Initialize;
Application
.
WebModuleClass := WebModuleClass;
TISAPIApplication(Application).OnTerminate := DoTerminate;
//added
Application
.
Run;
end
.
Source [WayBack] How to properly cleanup/shutdown a Delphi ISAPI (which uses Threads) | Mathias Pannier programmiert
Related:
- [WayBack] QualityCentral: 80186 Worker Thread deadlock on WebBroker App Unload
Worker Threads in Webbroker application may deadlock when you unload the application with IIS Admin. This then requires an IISReset which stops all other Web Applications.
I typically use a worker thread for logging in WebBroker applications. In the finalization of the unit containing the logging thread, I Destroy the Logger TThread object.
When the TThread.Destroy is called, it will call WaitFor if TThread.FFinished is not True. The WaitFor call will not return. To avoid this you need to delay the call to TThread.Destroy until TThread.FFinished is True.
This can be done by waiting until the DoTerminate method is called. See workaround.
(Note this problem has existed for many previous versions of Delphi)
- [Archive.is] (11) Delphi MVC Framework:isapi issue with the loggerpro
- [Archive.is] (11) Delphi MVC Framework: ISAPI issue
–jeroen