Mega Search
23.2 Million


Sign Up

Make a donation  
GUI freeze using [FindFirstFileEx / FindNextFile]  
News Group: embarcadero.public.delphi.non-technical

Hi all! I'm programming a small program that list the directories every X time and save the result in an array. The problem is coming when I try to list big directories like "C: \windows\system32", the GUI is freezing. I'm using the API's FindFirstFileEx / FindNextFile for list the content of any directory. If someone could give me any solution please.

Thanks in advance. Best regards.

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 25-Nov-2012, at 9:12 AM EST
From: Samuel Pedrosa
 
Re: GUI freeze using [FindFirstFileEx / FindNextFile]  
News Group: embarcadero.public.delphi.non-technical
Samuel Pedrosa wrote:
> Hi all! I'm programming a small program that list the directories
> every X time and save the result in an array. The problem is coming
> when I try to list big directories like "C: \windows\system32", the
> GUI is freezing. I'm using the API's FindFirstFileEx / FindNextFile
> for list the content of any directory. If someone could give me any
> solution please.     

It is common practice to move blocking, lengthy tasks into a separate
thread. The main thread should be doing not much else than GUI-stuff.

-- 
Arno Garrels

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 25-Nov-2012, at 10:45 AM EST
From: Arno Garrels
 
Re: GUI freeze using [FindFirstFileEx / FindNextFile]  
News Group: embarcadero.public.delphi.non-technical
Thanks for your response. I implemented my class to multithread class and i replaced the method to list the directories :) . All work fine!

Best regards.

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 25-Nov-2012, at 3:54 PM EST
From: Samuel Pedrosa
 
Re: GUI freeze using [FindFirstFileEx / FindNextFile]  
News Group: embarcadero.public.delphi.non-technical
On Sun, 25 Nov 2012 09:12:33 -0800, Samuel Pedrosa <> wrote:

>Hi all! I'm programming a small program that list the directories every X time and save the result in an array. The problem is coming when I try to list big directories like "C: \windows\system32", the GUI is freezing. I'm using the API's FindFirstFileEx / FindNextFile for list the content of any directory. If someone could give me any solution please.
>
>Thanks in advance. Best regards.

If you want to get rid of the freeze you'll have to move the slow
stuff to a thread.  It gets ugly.

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 25-Nov-2012, at 4:19 PM EST
From: Loren Pechtel
 
Re: GUI freeze using [FindFirstFileEx / FindNextFile]  
News Group: embarcadero.public.delphi.non-technical
Samuel wrote:

> The problem is coming when I try to list big directories like "C: \windows\system32",
> the GUI is freezing.

As others have said, you should move the iteration to a separate worker thread. 
 However, if you just want to keep your UI painting responsive, but not allow 
the user to inteact with the UI, you don't need to use a thread.  You can 
just call the Form's Update() method periodically inside your iteration, 
such as every X number of files, or use MsgWaitForMultipleObjects() to check 
for pending messages, or at least PeekMessage() to check for pending WM_PAINT 
messages specifically.

--
Remy Lebeau (TeamB)

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 26-Nov-2012, at 10:42 AM EST
From: Remy Lebeau (TeamB)
 
Re: GUI freeze using [FindFirstFileEx / FindNextFile]  
News Group: embarcadero.public.delphi.non-technical
Am 25.11.2012 18:12, schrieb Samuel Pedrosa:
> Hi all! I'm programming a small program that list the directories every X time and save the result in an array. The problem is coming when I try to list big directories like "C: \windows\system32", the GUI is freezing. I'm using the API's FindFirstFileEx / FindNextFile for list the content of any directory. If someone could give me any solution please.
> 
> Thanks in advance. Best regards.
> 

Hello,

another tip: that question would have been a suitable candidate for the
..rtl or the vcl.components.using groups.
This here is about general more non technical topics.

Greetings

Markus

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 26-Nov-2012, at 1:05 PM EST
From: Markus Humm