Threads problem with FastReport and custom Delphi Server

Hi,

Fastreport supports thread, and it should be created like that inside a thread :

FReport := TfrxReport.Create( nil );
frxReport.EngineOptions.EnableThreadSafe := True;
frxReport.EngineOptions.DestroyForms := False;
frxReport.EngineOptions.ReportThread := Thread;

my service is like that :
function TWSYCatService.getInvoice(const FRTemplate: AnsiString; const orderID: AnsiString; out Stream: Binary): Boolean;
begin
create the report here and do the printing.
end;

But I have to pass the thread to the ReportThread property, how can I do this ?

Regards

Armindo

1 Like

Hello,

You could get id of current thread using Windows.GetCurrentThreadId function:

FReport := TfrxReport.Create( nil );
frxReport.EngineOptions.EnableThreadSafe := True;
frxReport.EngineOptions.DestroyForms := False;
frxReport.EngineOptions.ReportThread := Windows.GetCurrentThreadId;

Best regards

Hi,
in fact it expects a TThread object GetCurrentThreadId is a cardinal;
Regards

Hello,

Then try to use TThread.CurrentThread

var thr:TThread;

FReport := TfrxReport.Create( nil );
frxReport.EngineOptions.EnableThreadSafe := True;
frxReport.EngineOptions.DestroyForms := False;
thr:= TThread.CurrentThread;
frxReport.EngineOptions.ReportThread := thr;

Best regards

1 Like

I can compile but I still get an error 1400 Invalid window handle.
Will try to investigate this with FR.

1 Like