private void _sessionManagerEvents_onDeviceStateChanged(COMStateDeviceEventArgs deviceEventArgs) { if (deviceEventArgs.DeviceState == DeviceChangeState.DeviceState_Removed) { OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_device_detached, "Device detached.")); } // device may have arrived or been removed. Either way detach device event handlers, then try to re-attach them DetachDevice(); AttachDevice(); }
// print session manager events void m_sessionComManager_DeviceStateChanged(COMStateDeviceEventArgs e) { // if our "Active device" was unplugged, detach from it and attach to new one (if available) if (e.DeviceState == DeviceChangeState.DeviceState_Removed && m_activeDevice != null) // && string.Compare(e.DevicePath, m_activeDevice.DevicePath, true) == 0) { DetachDevice(); AttachDevice(); // attach next available device (if any) } else if (e.DeviceState == DeviceChangeState.DeviceState_Added) { // if we previously had an attached device, first unattach it: if (m_activeDevice != null) { DetachDevice(); m_activeDevice = null; } // if device is plugged, and we don't have "Active device", just attach to it AttachDevice(); } }
private static void _sessionManagerEvents_onDeviceStateChanged(COMStateDeviceEventArgs deviceEventArgs) { // device may have arrived or been removed. Either way detach device event handlers, then try to re-attach them DetachDevice(); AttachDevice(); }