Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:02:56+00:00 2026-06-01T12:02:56+00:00

In my windows form application, I’m trying to test the user’s ability to access

  • 0

In my windows form application, I’m trying to test the user’s ability to access a remote machine’s shared folder. The way I’m doing this (and I’m sure that there are better ways…but I don’t know of them) is to check for the existence of a specific directory on the remote machine (I’m doing this because of firewall/other security restrictions that I’m confronted with in my organization). If the user has rights to access the shared folder, then it returns in no time at all, but if they don’t, it hangs forever. To solve this, I threw the check into another thread and wait only 1000 milliseconds before determining that the share can’t be hit by the user. However, when I do this, it still hangs as if it was never run in the same thread.

What is making it hang and how do I fix it? I would think that the fact that it is in a separate thread would allow me to just let the thread finish on it’s own in the background.

Here is my code:

bool canHitPath = false;
Thread thread = new Thread(new ThreadStart(() =>
{
    canHitPath = Directory.Exists(compInfo.Path);
}));
thread.Start();
thread.Join(1000);

if (canHitPath == false)
{
    throw new Exception("Cannot hit folder: " + compInfo.Path);
}

Edit: I feel that I should add that the line of throwing the exception IS HIT. I’ve debugged this and verified it…however, when the exception is thrown, then is when my program hangs. (I might also add that the exception is caught in the calling method and I never get to the catch statement in the debugger.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:02:58+00:00Added an answer on June 1, 2026 at 12:02 pm

    I found the real problem:

    The property compInfo.Path is doing a check for a directory existence on the remote file system to determine if the remote machine is 64 bit or not. Depending on the results, it returns a different value. I tried commenting out the the check and it executed successfully. This explains why I couldn’t get past the throwing of the exception, I call compInfo.Path in the message of the exception.

    However, I think we learned a lot from “the real problem”:

    1. The code I posted in the question (as is) works perfectly fine.
    2. thread.Join(int) will exit after the specified time interval regardless of the fact that the thread may still be executing code.
    3. The thread being joined CAN be running an IO operation (thus tying up a file/directory) and the desired result will still come about when doing a thread.Join(int).
    4. Using the “step into” button on a debugger will reveal many things…even about your own “solid” code. 🙂

    Thanks everyone for your help, patience, and thoughtful input/insights.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Windows Form application that supplies the User Name, Domain, and Password
I have a windows form application that uses a Shared class to house all
I have a windows form application which let an user to write in a
I've a windows form application where it ask the user to login before loading
I have a windows form application(c#) and an asp.NET web application which both access
Creating My Windows Form Application and using ADO.Net as Data Access layer and SQL
I have a windows form application. On the main form a user will enter
Am building windows form application for a Hospital using VS2010 ON ACCESS 2010. I
I m working on windows form application. I need to show amount in words
I have a C# Windows Form application that contains a menu with this event:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.