Thread hanging/FolderBrowseDialog problem

  • Thread starter Thread starter Andrue Cope
  • Start date Start date
A

Andrue Cope

Hi,

We have a strange problem. We are invoking the FolderBrowseDialog and
have found that if we cancel that dialog within a few seconds of it
appearing it causes one of our (completely unrelated) background
threads to hang on program shut down.

Details:
Background thread is sitting idle waiting for work. This thread has
nothing to with the folder selection activity - it's a completely
separate part of the application.

In unrelated code the user causes the FolderBrowseDialog to appear then
quickly cancels it.

On program exit the background thread is terminated successfully but
the code waiting for it to terminate:

while(workerThread.IsAlive)
Thread.Sleep(100);

Never terminates.



We have put breakpoints in the worker thread that show that it detects
our stop flag and exits correctly.

It looks to us like the FolderBrowseDialog is causing the .NET thread
manager to block and it never gets around to setting IsAlive to false.

FWIW:This problem is most prevalent on machines with one or more slow
drive mappings. If users select [OK] it isn't an issue. If users wait
half a minute before selecting [Cancel] it isn't normally a problem
either. It seems to relate to the dialog box populate itself in a
background thread.

--
 
Sounds like an interesting problem.
I have a suggestion to use as a work-around.

Can you launch the folder browse dialog on another thread that is separate
from the main UI thread. I would recommend using the BackgroundWorker
component.

--
Good luck!

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
 
Back
Top