Solved

Delphi Multi thread example

Posted on 2013-05-17
3
1,461 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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