views:

397

answers:

1

Hi,

I am writing a file manager in .NET 3.5. At startup, the application must enumerate available drives. I am using DriveInfo.GetDrives to do that.

Unfortunately my users lamented that, when they have disconnected network drives, the application took about 30 seconds to start.

I discovered that the GetDrives() function hangs for many seconds when you have a disconnected network drive. And the UI freezes. This happens at startup, and each time I attach a new drive.

To sum up, I need a way to enumerate available drives which returns immediately, even though there are disconnected network drives. Thanks for any help.

Additional informations:

  1. I did some test with WMI, and the same problem arises. The WMI query returns after 15 seconds or so.

  2. I have also considered moving the call to DriveInfo to a separate thread. This would solve the problem of not blocking the user interface; but it would mean that, when the user attaches a new drive, the drive icon would only appear after 15 seconds. That is not ideal.

Thank you very much for any help.

A: 

I fear that there isno way to avoid the blocking. It is due to network/file timeouts in Windows API.

PVitt