Solved

Delphi Multi thread example

Posted on 2013-05-17
3
1,390 Views
Last Modified: 2013-06-02
Hello,

Let's say I have a procedure called "DoItForALongTime" which runs for 30 seconds.

The user can start it clicking on the Start button.
But after starting the  "DoItForALongTime" procedure, the user should be able to click on the Start button again and again so as many  "DoItForALongTime" procedures can run at the same time (of course with delayed start).

I would like to have a small working Delphi application about this. It doesn't matter what the  "DoItForALongTime" procedure does, only it should last for at least 20 seconds.

I use Delphi 2010.

Thank you very much
0
Comment
Question by:starhu
3 Comments
 
LVL 25

Accepted Solution

by:
Sinisa Vuk earned 250 total points
ID: 39174238
I recommend to use TBMDThread. Get it from www.torry.net
OmniThreadLibrary is little complex but good alternative too. Using one of them you can easily set you "long" process as a working job.
0
 
LVL 15

Assisted Solution

by:mikelittlewood
mikelittlewood earned 250 total points
ID: 39189982
I would also take a look at the JVCL open source components.
They have a TJVThread set of components.
0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 39190869
you might want to consider your approach
technically
hitting the button adds a todo item to a list
this list is checked by a thread periodically
when a item is on the list, it is removed and a thread is started to do the work
if you want only 1 thread to run at a time, you would let the first thread keep count of how many threads are running or were started > the number of simultaneous threads which can run at the same time is called throttling
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now