Solved

Delphi Multi thread example

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

734 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