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 // 12 // SuspensionManager.h 13 // Declaration of the SuspensionManager class 14 // 15 16 #pragma once 17 18 #include <ppltasks.h> 19 20 namespace SDKSample 21 { 22 namespace Common 23 { 24 /// <summary> 25 /// SuspensionManager captures global session state to simplify process lifetime management 26 /// for an application. Note that session state will be automatically cleared under a variety 27 /// of conditions and should only be used to store information that would be convenient to 28 /// carry across sessions, but that should be disacarded when an application crashes or is 29 /// upgraded. 30 /// </summary> 31 ref class SuspensionManager sealed 32 { 33 internal: 34 static void RegisterFrame(Windows::UI::Xaml::Controls::Frame^ frame, Platform::String^ sessionStateKey); 35 static void UnregisterFrame(Windows::UI::Xaml::Controls::Frame^ frame); 36 static Concurrency::task<void> SaveAsync(void); 37 static Concurrency::task<void> RestoreAsync(void); 38 static property Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ SessionState 39 { 40 Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ get(void); 41 }; 42 static Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ SessionStateForFrame( 43 Windows::UI::Xaml::Controls::Frame^ frame); 44 45 private: 46 static void RestoreFrameNavigationState(Windows::UI::Xaml::Controls::Frame^ frame); 47 static void SaveFrameNavigationState(Windows::UI::Xaml::Controls::Frame^ frame); 48 }; 49 } 50 } 51