protected void StartDevice() { TerminateAllCommThreads(); lock (this) { if (cf635 == null) { const int BAUD = 115200; // 115200 for (int i = 0; i < 10; i++) { try { cf635 = new CrystalFontz635(BAUD, "COM3"); break; } catch (Exception ex) { Thread.Sleep(100); cf635 = null; } } if (cf635 == null) throw new InvalidOperationException("Failed to create device"); cf635.Reset(); cf635.SetCursorStyle(CursorStyles.None); cf635.OnKeyDown += new KeyDownEventHandler(cf635_OnKeyDown); } } }