Solved

New form thread

Posted on 2007-11-20
6
227 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
[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
  • 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
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!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month6 days, 21 hours left to enroll

623 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