Jinjinov / Usb.Events

Subscribe to the Inserted and Removed events to be notified when a USB drive is plugged in or unplugged, or when a USB device is connected or disconnected. Usb.Events is a .NET Standard 2.0 library and uses WMI on Windows, libudev on Linux and IOKit on macOS.
MIT License
95 stars 23 forks source link

Null checks in disposing #15

Closed thomOrbelius closed 3 years ago

thomOrbelius commented 3 years ago

Simple fix for #14.

Add basic null checks when disposing the Windows specific objects. In the Test application, the event registration is wrapped in a method that disposes the UsbEventWatcher.

The PR has been tested on Windows 10 and Ubuntu 20.04. It would be a good idea to test it in on other platforms as well (Mac, other Linux)

Jinjinov commented 3 years ago

Thank you!