Skip to content

Commit 7717c95

Browse files
committed
Prevent Unwanted DeviceWatcher Stops
1 parent bf9062d commit 7717c95

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Files UWP/App.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,10 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
621621
{
622622
var deferral = e.SuspendingOperation.GetDeferral();
623623
//TODO: Save application state and stop any background activity
624-
watcher.Stop();
624+
if(watcher.Status == DeviceWatcherStatus.Started || watcher.Status == DeviceWatcherStatus.EnumerationCompleted)
625+
{
626+
watcher.Stop();
627+
}
625628
deferral.Complete();
626629
}
627630
}

0 commit comments

Comments
 (0)