You are correct, the correct answer to your problem is to use an thread. To do
that you'll need to make a descendent of TThread and all the work in the
Execute method. Ex:
type
TMyTestThread = class(TThread)
public
procedure Execute;override;
end;
procedure TMyTestThread.Execute;
begin
// Your code goes here.
end;
If you do go this route you'll need to pay attention to thread-safety between
this worker and the VCL thread. Essentially you can't directly access elements
on form to provide status information (you'll need to use synchronized calls to
do that, or send windows messages). You'll also need to make sure the VCL
doesn't use any of the components you use in your thread until the thread is
done processing.
If this sounds like too much trouble, there might be ways to keep your existing
code and make sure the form gets updated. For example, if you're using Indy
components you can add an IdAntiFreeze to your form and this will in turn take
care of the windows updates. You may also rewrite your application to use
F.Piette's ICS suite of components (I assume you're not using ICS at the moment
since ICS works asynchronically so it doesn't block).
If you need more assistance please tell us a bit more about your application:
What kind of components are you using for internet access, what other
non-visual components are you using (TTable?), what are you using to display
status information (TLabel? ProgressBar?).
--
Cosmin Prund
> -----Mesaj original-----
> De la: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] În
> numele Rainer von Saleski
> Trimis: Friday, August 15, 2008 12:15 AM
> Către: [email protected]
> Subiect: Windows Update Thread
>
> Hi,
>
> I need to create a thread (I think) to allow screen updates to happen
> during a 5-minute processing step that does heavy internet access. I
> tried simply putting .Update calls inside my loop, but about one run in
> 5, the screen just stops updating until processing completes. Sort of
> defeats the purpose of keeping the user informed.
>
> What's the best way to do this? (Delphi 7, in case it matters)
>
> Thanks,
> Rainer
>
> _______________________________________________
> Delphi mailing list -> [email protected]
> http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi