Thread.Interrupt() doesn't interrupt a thread that is in a sleeping state?


  • Microsoft's and can take FOREVER, especially if you're in a situation, where you've unplugged from the network and you're looking in a share.

    So, to get around this, I've created a thread that times out after 3 seconds.  Returning false, if the calls above haven't yet returned.
    To do this, my main thread passes its instance to the new thread and immediately calls:

    Thread.Sleep(TimeOutInSeconds * 1000) ' Where TimeOUtInSeconds = 3
    The new thread then goes and checks for the file / folder using the / functions.
    Regardless of the result, then it uses the main thread's reference to call Thread.Interrupt().

    My main thread doesn't get interrupted.  It stays there for the full 3 seconds.
    If I were to change that to 3 minutes ( and I have ), it'll sleep for 3 minutes.

    Any ideas?
    I'm just wondering if anyone has seen this before?
    Tuesday, August 18, 2009 5:25 PM