protected override void SetVisibleCore(bool value) { // Prevent window getting visible if (mInstance == null) { try { if (!this.IsHandleCreated) { CreateHandle(); } } catch (Exception ex) { LogHelper.Log.Error(ex.Message); } mInstance = this; } base.SetVisibleCore(false); if (DeviceAttached != null) { DeviceAttached(null); //首次运行 扫描已经插入设备 } }
protected override void SetVisibleCore(bool value) { // Prevent window getting visible if (mInstance == null) { mInstance = this; try { CreateHandle(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } base.SetVisibleCore(false); }
public static void Stop() { try { if (mInstance == null) { throw new InvalidOperationException("还未启动监测"); } if (th != null && th.ThreadState != System.Threading.ThreadState.Stopped) { th.Abort(); } mInstance.CrossThreadCalls(() => { mInstance.EndForm(); }); } catch (Exception ex) { LogHelper.Log.Error(ex.Message); } mInstance = null; th = null; }