WindowsDeviceNotifier creates a NativeWindow to listen for WM_DEVICECHANGE events, but this only works when messages are getting pumped, which requires an STAThread and Application.Run() to be called. This works fine in WinForms and WPF applications, but in console apps, this is not the case. WindowsDeviceNotifier.cs should be patched to spin up an STAThread and run Application.Run() to work properly:
public void StaThread()
{
mNotifyWindow = new DevNotifyNativeWindow(OnHandleChange, OnDeviceChange);
Application.Run();
}
public WindowsDeviceNotifier()
{
if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
{
mNotifyWindow = new DevNotifyNativeWindow(OnHandleChange, OnDeviceChange);
}
else
{
Thread staThread = new Thread(new ThreadStart(StaThread));
staThread.SetApartmentState(ApartmentState.STA);
staThread.Name = "DevNotifyNativeWindow STA Thread";
staThread.Start();
}
}