Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Threading- is this a good way? 1

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
AU
I have created an application and have implemented threading like this:

Code:
[b]implementation[/b]
var
...

//type for retrieving invoices --> runs in it's own thread
type TRetrieveInvoice = class(TThread)
  protected
    procedure Execute; override;
end;

...


//procedure to start a Mass Import
procedure TfrmMain.InitiateImport;
var
  InvoiceThread : TRetrieveInvoice;
begin
  //begin importing items and descriptions
  InvoiceThread := TRetrieveInvoice.Create(True);
  InvoiceThread.FreeOnTerminate := True;
  InvoiceThread.Resume;
end;

...

//execute invoice in own thread
procedure TRetrieveInvoice.Execute;
var
..
begin
...
end;


Is this an acceptable way to use threads, or is there a better way. Thanks in advance.




------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
that's the way to get started. I imagine you may run into issues further down the track as your thread accesses objects in the main thread.

But, what you've got there is a solid way to begin threading.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top