Solved

New form thread

Posted on 2007-11-20
6
220 Views
Last Modified: 2010-04-05
I have small problem (delphi7) how to make thread in new form, now I have app with many forms but if in some form I start some job then freeze all app forms, how to make like one form are in threed and if there going some job
example:

for a:= 0 to 1000 do
  begin
    sleep 10000
  end;


  I can this form minimize and work with main form!!!!
0
Comment
Question by:KarlisB
  • 3
  • 3
6 Comments
 
LVL 19

Expert Comment

by:MerijnB
Comment Utility
it's probably easier to call
Application.ProcessMessages in each itteration:
for a:= 0 to 1000 do

  begin

    sleep(1000);

    Application.ProcessMessages();

  end;

Open in new window

0
 
LVL 3

Author Comment

by:KarlisB
Comment Utility
I try in my app like this but that did not work well, there I have 300 lines code with many loops and sql querys, there updating data from one db to many other db, sometimes some query take 10 sec. (not a local DB) and there anyway app freezes !!!!  
0
 
LVL 19

Accepted Solution

by:
MerijnB earned 500 total points
Comment Utility
you can make a thread in your form, but it requires some knowledge on async programming etc.
You can not just let a certain form be run from another thread nor can you do screen updates (or changes to any vcl for that matter) from another thread.

Take a look at TThread, this is a quite convenient way to make a process in a separate thread in delphi.

See also here for more info: http://delphi.about.com/od/kbthread/Threading_in_Delphi.htm
0
Highfive Gives IT Their Time Back

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!

 
LVL 3

Author Comment

by:KarlisB
Comment Utility
huhhhh it looks too complicated for me :( I`m beginner in delphi, is not any possibility to make new thread when creating new form and then any job what is going in this form are work separately???
0
 
LVL 19

Expert Comment

by:MerijnB
Comment Utility
no, unfortunately, working with threads just _is_ complicated, it does not matter what language you are programming in.

The DB you are using can probably also handle it's query's in an async way but I'm not that familiar with that, maybe someone else can say something about that?

We could type out a thread for you, but you will probably get in trouble as soon as you need to make some changes or there is a problem and don't understand the principle.
0
 
LVL 3

Author Comment

by:KarlisB
Comment Utility
I install the component EZThread works wery wery good, he is wery simple, and easy to use, but MerijnB thanks anyway for information!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

12 Experts available now in Live!

Get 1:1 Help Now