Skip to content

Commit 24ee369

Browse files
authored
Resume devicewatcher after suspending (#1819)
1 parent d20ecff commit 24ee369

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Files/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ private void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e)
7979
{
8080
// Need to reinitialize AppService when app is resuming
8181
InitializeAppServiceConnection();
82+
AppSettings?.DrivesManager?.StartDeviceWatcher();
8283
}
8384

8485
public static AppServiceConnection Connection;

Files/Filesystem/Drives.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ private async void EnumerateDrives()
5050
};
5151
}
5252

53-
private void StartDeviceWatcher()
53+
public void StartDeviceWatcher()
5454
{
55+
this.Dispose();
5556
_deviceWatcher = DeviceInformation.CreateWatcher(StorageDevice.GetDeviceSelector());
5657
_deviceWatcher.Added += DeviceAdded;
5758
_deviceWatcher.Removed += DeviceRemoved;

0 commit comments

Comments
 (0)