cec-config-gui: open the connection in the background thread
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 19:51:18 +0000 (20:51 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 19:51:18 +0000 (20:51 +0100)
src/cec-config-gui/CecConfigGUI.cs
src/cec-config-gui/actions/ConnectToDevice.cs

index 6d5bb47a0024eefcfb01cd54950ab644ca82887e..b2b6c557038bd60a531073155863e55370363e2a 100644 (file)
@@ -39,14 +39,6 @@ namespace CecConfigGui
       InitializeComponent();
       LoadButtonConfiguration();
 
-      //TODO read the com port setting from the configuration
-      CecAdapter[] adapters = Lib.FindAdapters(string.Empty);
-      if (adapters.Length == 0 || !Lib.Open(adapters[0].ComPort, 10000))
-      {
-        MessageBox.Show("Could not connect to any CEC adapter. Please check your configuration and try again.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK);
-        Application.Exit();
-      }
-
       ActiveProcess = new ConnectToDevice(ref Lib, Config);
       ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
       (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
index cb84a00b403d6b75b22087f984d26f47fd2f2bde..a1e1ef6a9bbc59f05b5ece7d0dcd5febb18f604b 100644 (file)
@@ -13,6 +13,17 @@ namespace CecConfigGui.actions
 
     public override void Process()
     {
+      SendEvent(UpdateEventType.StatusText, "Opening connection...");
+      SendEvent(UpdateEventType.ProgressBar, 10);
+
+      //TODO read the com port setting from the configuration
+      CecAdapter[] adapters = Lib.FindAdapters(string.Empty);
+      if (adapters.Length == 0 || !Lib.Open(adapters[0].ComPort, 10000))
+      {
+        MessageBox.Show("Could not connect to any CEC adapter. Please check your configuration and try again.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK);
+        Application.Exit();
+      }
+
       SendEvent(UpdateEventType.StatusText, "Detecting TV vendor...");
       SendEvent(UpdateEventType.ProgressBar, 25);
       SendEvent(UpdateEventType.TVVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.Tv));