Generate a report using thread in the background

Asked

Viewed 252 times

1

I want to generate a report, but I want the system to be free for the user to do other activities while there is no report return. For this I am using thread, only when I close the form is giving error because the thread needs form information and as it was closed it is no longer in memory.

Does anyone have any suggestions?

1 answer

2

In the thread you can make a new implementation of constructor where you will pass all the data that it needs in order to be independent of the form, which when destroyed, will not compromise the execution of Thread.

Stay like this:

interface
  TRelatoriorThread = class(TThread)
  public
    constructor Create(const aParam1: string; aParam2: Integer...);
  end;

implementation
  constructor TRelatoriorThread.Create(const aParam1: string; aParam2: Integer...);
  begin
    inherited Create;
    FParam1 := aParam1;
    FParam2 := aParam2;
    ...
  end;

So you prepare the thread and it runs independently of the object that started it, it can be form, datamodule or anything else that one day will exist.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.