private void InitalizeDevice() { if (this.IsHandleCreated) { MethodInvoker mi = () => { this.ApplicationpicBoxWait.Enabled = false; this.ApplicationpicBoxWait.Visible = false; }; if (InvokeRequired) { BeginInvoke(mi); } else { Invoke(mi); } } try { devicePlugin = new IPA.DAL.RBADAL.DeviceCfg() as IDevicePlugIn; new Thread(() => { Thread.CurrentThread.IsBackground = true; try { // Initialize Device devicePlugin.OnDeviceNotification += new EventHandler <DeviceNotificationEventArgs>(this.OnDeviceNotificationUI); devicePlugin.DeviceInit(); Debug.WriteLine("main: loaded plugin={0} ++++++++++++++++++++++++++++++++++++++++++++", (object)devicePlugin.PluginName); } catch (Exception ex) { Logger.error("main: exception={0}", (object)ex.Message); if (ex.Message.Equals("NoDevice")) { WaitForDeviceToConnect(); } else if (ex.Message.Equals("MultipleDevice")) { this.Invoke(new MethodInvoker(() => { MessageBoxEx.Show(this, "Multiple Devices Detected\r\nDisconnect One of them !!!", "ERROR: MULTIPLE DEVICES DETECTED", MessageBoxButtons.OK, MessageBoxIcon.Error); WaitForDeviceToConnect(); })); } } }).Start(); } catch (Exception exp) { Logger.error("main: Initalize() - exception={0}", (object)exp.Message); } }
private void InitalizeDevice(bool unload = false) { // Unload Domain if (unload && appDomainCfg != null) { appDomainCfg.UnloadPlugin(appDomainDevice); // Test Unload appDomainCfg.TestIfUnloaded(devicePlugin); } appDomainCfg = new AppDomainCfg(); // AppDomain Interface appDomainDevice = appDomainCfg.CreateAppDomain(MODULE_NAME); // Load Interface devicePlugin = appDomainCfg.InstantiatePlugin(MODULE_NAME, appDomainDevice); // Initialize interface if (devicePlugin != null) { // Disable Tab(s) this.tabPage1.Enabled = false; this.tabPage2.Enabled = false; this.tabPage3.Enabled = false; this.tabPage4.Enabled = false; new Thread(() => { Thread.CurrentThread.IsBackground = true; Debug.WriteLine("\nmain: new device detected! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); // Setup DeviceCfg Event Handlers devicePlugin.initializeDevice += new DeviceEventHandler(this.InitalizeDeviceUI); devicePlugin.unloadDeviceconfigDomain += new DeviceEventHandler(this.UnloadDeviceConfigurationDomain); devicePlugin.processCardData += new DeviceEventHandler(this.ProcessCardDataUI); devicePlugin.processCardDataError += new DeviceEventHandler(this.ProcessCardDataErrorUI); devicePlugin.getDeviceConfiguration += new DeviceEventHandler(this.GetDeviceConfigurationUI); devicePlugin.setDeviceConfiguration += new DeviceEventHandler(this.SetDeviceConfigurationUI); devicePlugin.setDeviceMode += new DeviceEventHandler(this.SetDeviceModeUI); devicePlugin.setExecuteResult += new DeviceEventHandler(this.SetExecuteResultUI); devicePlugin.showJsonConfig += new DeviceEventHandler(this.ShowJsonConfigUI); if (tc_show_json_tab && dev_usb_mode == DEV_USB_MODE.USB_HID_MODE) { this.Invoke(new MethodInvoker(() => { this.picBoxJsonWait.Visible = true; tabControl1.SelectedTab = this.tabPage5; })); } // Initialize Device devicePlugin.DeviceInit(new AppConfigWrapper()); Debug.WriteLine("main: loaded plugin={0} ++++++++++++++++++++++++++++++++++++++++++++", (object)devicePlugin.PluginName); UpdateUI(); }).Start(); } }