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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Threads in Delphi

Status
Not open for further replies.

Megsie

Programmer
Dec 12, 2002
2
NZ
Hi I am looking at implementing a data compression and recovery algorithm in Delphi, and i have been looking for information on running multiple threads.

I can't seem to find any information about multiple threads for Delphi, is this because I am not looking in the right place, or does Delphi not support programming using multiple threads?
 
Some info on threads:

Delphi provides a TThread class that allows you to create and control threads. It is an abstract class so you do not use it directly. You can set up a thread by using the Thread Object in the New Items dialog box (File -> New -> Other).

Check out the Delphi help under TThread.

There's also a demo called Threads which you should be able to find in your Delphi directory e.g. for me the address is:
c:\Program Files\Borland\Delphi6\Demos\Threads

Hope this helps. Clive [infinity]
 
hi

Have a look in the help for TThread, there's a good simple example in there and located at Help\Examples\PrgrsBar. One useful command not mentioned in this example is Synchronise.

Good examples can be found on the web. Have you tried searching in Google for something like 'TThread Delphi'?

lou
 
That should be Synchronize, sorry. Search in help, there's a tiny example of it.
 
Thanks guys this really helps...

:)

Megsie [ponytails2]
 
Agree with the upstair comments.

Just to Create a New Application use template "Thread", this will be useful.

Attention: if you want to call a VCL function such as "Label1.Caption:='Hello, guys'" within you Thread function scope, you must do it in this way:

procedrue TThread1.ChangeCaption;
begin
Form1.Label1.Caption:='Hello, guys.';
end;


then call it in this way:

procedure TThread1.Execute;
begin
...
Synchronize(ChangeCaption);
...
end;

OR Your application would crash!

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top