suspensionmanager.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //*********************************************************
  2. //
  3. // Copyright (c) Microsoft. All rights reserved.
  4. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  5. // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  6. // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
  7. // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
  8. //
  9. //*********************************************************
  10. //
  11. // SuspensionManager.h
  12. // Declaration of the SuspensionManager class
  13. //
  14. #pragma once
  15. #include <ppltasks.h>
  16. namespace SDKSample
  17. {
  18. namespace Common
  19. {
  20. /// <summary>
  21. /// SuspensionManager captures global session state to simplify process lifetime management
  22. /// for an application. Note that session state will be automatically cleared under a variety
  23. /// of conditions and should only be used to store information that would be convenient to
  24. /// carry across sessions, but that should be disacarded when an application crashes or is
  25. /// upgraded.
  26. /// </summary>
  27. ref class SuspensionManager sealed
  28. {
  29. internal:
  30. static void RegisterFrame(Windows::UI::Xaml::Controls::Frame^ frame, Platform::String^ sessionStateKey);
  31. static void UnregisterFrame(Windows::UI::Xaml::Controls::Frame^ frame);
  32. static Concurrency::task<void> SaveAsync(void);
  33. static Concurrency::task<void> RestoreAsync(void);
  34. static property Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ SessionState
  35. {
  36. Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ get(void);
  37. };
  38. static Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ SessionStateForFrame(
  39. Windows::UI::Xaml::Controls::Frame^ frame);
  40. private:
  41. static void RestoreFrameNavigationState(Windows::UI::Xaml::Controls::Frame^ frame);
  42. static void SaveFrameNavigationState(Windows::UI::Xaml::Controls::Frame^ frame);
  43. };
  44. }
  45. }