Пример #1
0
        /// <summary>
        /// Overriding the WndProc as we want to notify the observer with all notifications from the usb device, that is a DEV_BROADCAST_DEVINTERFACE and is the same Guid.
        /// </summary>
        /// <param name="m">
        /// The m.
        /// </param>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WmDeviceChange)
            {
                try
                {
                    var devBroadCastDeviceInterface = _marshalWrapper.PointerToStructure <BroadcastDeviceInterface>(m.LParam, typeof(BroadcastDeviceInterface));
                    if (devBroadCastDeviceInterface != null && devBroadCastDeviceInterface.Guid == DeviceGuid)
                    {
                        _observer.OnNext(_usbDeviceNotificationFactory.Create(DeviceGuid, m, devBroadCastDeviceInterface.Name));
                    }
                }
                catch (Exception e)
                {
                    _observer.OnError(e);
                }
            }

            base.WndProc(ref m);
        }