title: "The semaphore timeout period has expired" error for USB connection
body: <p>I'm getting this error...</p>
  
  <blockquote>
    <p>The semaphore timeout period has expired.</p>
  </blockquote>
  
  <p>On this line...</p>
  
  <blockquote>
    <p>ThePorts.ActivePort1.Open();</p>
  </blockquote>
  
  <p>...but I only get it from time to time. When it happens, it happens over and over again. Then the problem goes away, for hours or days, then it comes back.</p>
  
  <p>The serial port is a USB with a BlueTooth connected.</p>
  
  <p>I think this guy was having a very similar problem, but not in C#</p>
  
  <p><a href="https://stackoverflow.com/questions/6749681/freeze-on-serialport-open-deviceiocontrol-getcommstate-with-usbser-sys?answertab=active#tab-top">Freeze on SerialPort.Open / DeviceIoControl / GetcommState with usbser.sys</a></p>
  
  <p>As best I can estimate, I have read his entire problem, and the resulting comments, and the answer, but I really can't figure out which one fixed his problem, or if C# is significantly different from what he was experiencing.</p>
  
  <p>Thanks for any help for the clueless. This is the actual code where it's happening.</p>
  
  <pre><code>public static void Open_ActivePortWeWillUse(String Drone_StringNameFromUser)
  {
      SerialPort TempSerialPort = new SerialPort(Drone_StringNameFromUser, (int) SerialPortSpeed);
  
      ThePorts.ActivePort1 = TempSerialPort;
  
      ThePorts.ActivePort1.DataBits = 8;
      ThePorts.ActivePort1.Parity = Parity.None;
      ThePorts.ActivePort1.StopBits = StopBits.One;
  
      ThePorts.ActivePort1.DataReceived += new SerialDataReceivedEventHandler(OurBackGroundSerialPortReceiver);
  
      ThePorts.ActivePort1.Open();  // "Sometimes" Error hits here
  }
  </code></pre>