Unmentioned Delphi 10.2 Tokyo's bugfix:

Unmentioned Delphi 10.2 Tokyo's bugfix:
Parallel Programming Library can be used in DLL now!
In earlier versions TThreadPool will cannot auto shutdown in DLL.
Which causes FreeLibrary freeze after using TTask or TParallel.

Delphi 10.2 add the following code in the end of System.Threading:
{$IFDEF MSWINDOWS}
var
OldDLLShutdownProc: procedure = nil;

procedure DLLShutdown;
begin
ShutdownThreadPool;
if @OldDLLShutdownProc <> nil then
OldDLLShutdownProc;
end;

procedure RegisterDLLShutdown;
begin
OldDLLShutdownProc := DLLShutdownProc;
DLLShutdownProc := @DLLShutdown;
end;

initialization
if IsLibrary then
RegisterDLLShutdown;
{$ENDIF MSWINDOWS}
end.

Comments