title: SerialPort UnauthorizedAccessException
body: <p>Occasionally some of my integration tests are failing with the above message. I'm using the code below to ready the port. </p>
  
  <pre><code>            for(int i = 0; i &lt; 5; i++)
              {
                  try
                  {
                      port.Open();
                      if (port.IsOpen)
                          break;
                  }
                  catch (Exception e)
                  {
                      try
                      {
                          port.Close();
                      }
                      catch (Exception)
                      {}
                      Thread.Sleep(300);
                  }
              }   
  </code></pre>
  
  <p>My assumption is that because it can't be the current thread blocking the port (because it will try to close it), it must be another thread or process that has died without cleaning up properly (one of the other tests - nothing else accesses this port). Is there a way to reset the state of the <code>SerialPort</code> so that the new thread / process can access it again? </p>
  
  <p>Thanks, </p>
  
  <p>Richard</p>