Solved

New form thread

Posted on 2007-11-20
6
222 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
ID: 20319324
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
ID: 20319536
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
ID: 20319565
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
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.

 
LVL 3

Author Comment

by:KarlisB
ID: 20325896
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
ID: 20325934
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
ID: 20349248
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

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

861 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

25 Experts available now in Live!

Get 1:1 Help Now