Solved

Delphi Multi thread example

Posted on 2013-05-17
3
1,407 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 26

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 37

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 262
Filemaker 14 vs Delphi Embarcadero 7 186
creating threads in delphi 1 82
Delphi and Access based Enumeration 9 46
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

911 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

20 Experts available now in Live!

Get 1:1 Help Now