7.1.3. Client side with threads
You can find all source files of this example in the This example shows how you can use the "TfrxReportClient" component in the threads. Thread class: TfrxClientTestThread = class (TThread) protected private ErrorsCount: Integer; Log: TMemo; ThreadID: Integer; procedure AppendLog; procedure FinishLog; public constructor Create(C: TfrxServerConnection; RepName: String; Id: Integer; Rep: Integer; L: TMemo); destructor Destroy; override; end; Constructor of the TfrxClientTestThread class: constructor TfrxClientTestThread.Create(C: TfrxServerConnection; RepName: String; begin FreeOnTerminate := False; ErrorsCount := 0; ThreadId := Id; CountRep := Rep; Log := L; Report := TfrxReportClient.Create(nil); Report.EngineOptions.ReportThread := Self; Report.Connection := C; Report.ReportName := RepName; Resume; end; The method TfrxClientTestThread.Execute sends a request to the CountRep server. All resulting information is displayed in Memo1 by the "AppendLog" and "FinishLog" methods: procedure TfrxClientTestThread.Execute; var begin for i := 1 to CountRep do begin Report.PrepareReport; if not Terminated then begin ErrorsCount := ErrorsCount + Report.Errors.Count; end; end; Synchronize(FinishLog); end; Before starting this program, launch the server application described above (topic 7.1.1.) On press button "Thread test" execute the code below: procedure TMainForm.TestBtnClick(Sender: TObject); var Thread: TfrxClientTestThread; begin frxServerConnection1.Port := StrToInt(Port.Text); frxServerConnection1.Login := Login.Text; frxServerConnection1.Password := Password.Text; frxServerConnection1.Compression := Compression.Checked; if (Length(ProxyHost.Text) > 0) then begin frxServerConnection1.ProxyPort := StrToInt(ProxyPort.Text); end; ClearThreads; Memo1.Lines.Add('Start test'); j := StrToInt(Threads.Text); k := StrToInt(Rep.Text); for i := 1 to j do begin Thread := TfrxClientTestThread.Create(frxServerConnection1, ThreadList.Add(Thread); end; end; |
< previous page | main page | next page > |