Skip to content

Commit

Permalink
Use Resuming instead of OnLeavingBackground
Browse files Browse the repository at this point in the history
  • Loading branch information
gave92 committed Jun 19, 2021
1 parent 2734390 commit 7959b8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions Files/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public App()
TaskScheduler.UnobservedTaskException += OnUnobservedException;
InitializeComponent();
Suspending += OnSuspending;
LeavingBackground += OnLeavingBackground;
Resuming += OnResuming;

//LogManager.Configuration.Variables["LogPath"] = storageFolder.Path;
AppData.FilePreviewExtensionManager.Initialize(); // The extension manager can update UI, so pass it the UI dispatcher to use for UI updates
Expand Down Expand Up @@ -115,7 +115,7 @@ private static async Task EnsureSettingsAndConfigurationAreBootstrapped()
});
}

private void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e)
private void OnResuming(object sender, object e)
{
DrivesManager?.ResumeDeviceWatcher();
}
Expand Down Expand Up @@ -370,15 +370,10 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
SaveSessionTabs();

var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity

LibraryManager?.Dispose();
DrivesManager?.Dispose();
deferral.Complete();

#if DEBUG
Current.Exit();
#endif
deferral.Complete();
}

public static void SaveSessionTabs() // Enumerates through all tabs and gets the Path property and saves it to AppSettings.LastSessionPages
Expand Down
4 changes: 2 additions & 2 deletions Files/Helpers/AppServiceConnectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public static class AppServiceConnectionHelper
static AppServiceConnectionHelper()
{
App.Current.Suspending += OnSuspending;
App.Current.LeavingBackground += OnLeavingBackground;
App.Current.Resuming += OnResuming;
}

private static async void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e)
private static async void OnResuming(object sender, object e)
{
if (await Instance == null)
{
Expand Down

0 comments on commit 7959b8e

Please sign in to comment.