- /// (event) UsbConnected is raised when USB is connected/disconnected.
- /// </summary>
- public static event EventHandler<RuntimeKeyStatusChangedEventArgs> UsbConnected
- {
- add
- {
- if (s_usbConnected == null)
- {
- int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(RuntimeInformationKey.Usb, s_runtimeInfoChangedCallback, IntPtr.Zero);
- if (ret != (int)RuntimeInfoError.None)
- {
- Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler");
- RuntimeInfoErrorFactory.ThrowException(ret);
- }
- }
- s_usbConnected += value;
- }
- remove
- {
- s_usbConnected -= value;
- if (s_usbConnected == null)
- {
- int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(RuntimeInformationKey.Usb);
- if (ret != (int)RuntimeInfoError.None)
- {
- Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler");
- RuntimeInfoErrorFactory.ThrowException(ret);
- }
- }
- }
- }
- /// <summary>