BenjaminRay
New member
- Joined
- Aug 3, 2005
- Messages
- 3
- Programming Experience
- 1-3
Hey all,
I am having trouble accurately knowing when a thread has completed without holding up my application with loops & the like.
My basic goal is this: Run a recursive directory/file search program, and provide the user with a small progress indicator form with a Cancel option while they wait.
The search function runs as a thread, which allows the main form and the progress indicator form to continue to function while the work is being done. However, it's when I try to track the completion of the thread that I end up disabling the forms with either a loop or by telling it to wait for AutoResetEvent.WaitOne.
The problem is that when the main application is waiting for the event, it is completely frozen, which defeats the purpose of using a thread in the first place. And if I create a second thread to allow the progress indicator form to open up while the main application is held up, it doesn't stay open. (Why would it? The thread is told to open it, and it aborts when it has done its job.)
In the end, I my code is now more complicated, but I still have no access to either of the forms while I wait for the search to complete.
Can any of you help me out with this? It seems like checking for the thread's completion can't be done without holding up the entire application.
Thanks.
I am having trouble accurately knowing when a thread has completed without holding up my application with loops & the like.
My basic goal is this: Run a recursive directory/file search program, and provide the user with a small progress indicator form with a Cancel option while they wait.
The search function runs as a thread, which allows the main form and the progress indicator form to continue to function while the work is being done. However, it's when I try to track the completion of the thread that I end up disabling the forms with either a loop or by telling it to wait for AutoResetEvent.WaitOne.
The problem is that when the main application is waiting for the event, it is completely frozen, which defeats the purpose of using a thread in the first place. And if I create a second thread to allow the progress indicator form to open up while the main application is held up, it doesn't stay open. (Why would it? The thread is told to open it, and it aborts when it has done its job.)
In the end, I my code is now more complicated, but I still have no access to either of the forms while I wait for the search to complete.
Can any of you help me out with this? It seems like checking for the thread's completion can't be done without holding up the entire application.
Thanks.