title: How to enable two different C# applications accessing the same directory in a continuous thread?
body: <p>I have the <em>same</em> BackgroundWorker code piece in two simultaneously running applications. Will this code avoid the problem of same resource getting access by two processes and run smoothly?</p>
  
  <pre><code>void bw_DoWork(object sender, DoWorkEventArgs e)
      {
         bool flag = false;
         System.Threading.Thread.Sleep(1000);
  
         while (flag.Equals(false))
         {
  
             string dir = @"C:\ProgramData\Msgs";
             try
             {
                 if (Directory.GetFiles(smsdir).Length &gt; 0)
                 {                      
                     flag = true;
                 }
  
             }
             catch (Exception exc)
             {
                 Logger.Log("Dir Access Exception: " + exc.Message);
                 System.Threading.Thread.Sleep(10);
             }
         }        
  </code></pre>