In der Delphi-
RTL heißt es
TThread.ReturnValue
und ist aus unerfindlichen Gründen ein Integer aber...
Delphi-Quellcode:
program Project1;
uses
System.SysUtils,
System.Classes,
WinApi.Windows;
procedure p();
var
thread: TThread;
threadExitCode: DWORD;
begin
thread := TThread.CreateAnonymousThread(
procedure()
begin
TThread.SetReturnValue(42);
end
);
thread.FreeOnTerminate := False;
thread.Start();
thread.WaitFor();
Win32Check(
WinApi.Windows.GetExitCodeThread(thread.Handle, threadExitCode)
);
WriteLn('
Exit code: ', threadExitCode);
end;
begin
try
p();
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
ReadLn;
end.