troubleshooting Question

Queued Threads, but with a responsive GUI

Avatar of Mutley2003
Mutley2003 asked on
Delphi
13 Comments3 Solutions1315 ViewsLast Modified:
Hi
I have a thread class that goes through all the files on a drive, and calls synchronize to feed information back to the VCL thread. It works fine.

Now, I want to launch several of these threads in sequence, and still have the GUI being responsive. "In sequence" meaning that the nest thread should not start
until the previous thread has finished

like (pseudocode)

procedure buttonScanAllDrives.Click;
begin
 ThreadedProcessDrive('C');
 waitUntilFinished;
 ThreadedProcessDrive('D');
 waitUntilFinished;
 ThreadedProcessDrive('E');
end;

It is the WaitUntilFinished bit that has me confused. I tried setting a flag in OnTerminate and checking that in a loop with sleep and application.processMessages - bad news, unresponsive GUI.

Then I tried TThread.WaitFor .. same story

then I tried WaitForSingleObject (between the calls to ThreadedProcessDrive) .. same story.

hmmm .. do I need a supervisor thread that creates the others and resumes them ?

seems like a thread too many

ideas/code anyone?

thanks



ASKER CERTIFIED SOLUTION
Lee_Nover

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros