private async void OnScanDrives() { try { IsScanning = true; // Give time to show indicator to user await Task.Delay(2000); await _driveDetector.ScanAttachedDrivesAsync(); } catch (Exception ex) { _logger.Log(ex.Message, Category.Exception, Priority.High); } }
private IntPtr WindowsMessageHandler(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case WindowsMessages.WM_DEVICECHANGE: { switch ((int)wParam) { case WindowsMessages.DBT_DEVICEARRIVAL: case WindowsMessages.DBT_DEVICEREMOVECOMPLETE: { _driveDetector.ScanAttachedDrivesAsync(); break; } } break; } } return(IntPtr.Zero); }