AppStore.Common.SuspensionManager.RestoreAsync C# (CSharp) Method

RestoreAsync() public static method

Restores previously saved SessionState. Any Frame instances registered with RegisterFrame will also restore their prior navigation state, which in turn gives their active Page an opportunity restore its state.
public static RestoreAsync ( String sessionBaseKey = null ) : System.Threading.Tasks.Task
sessionBaseKey String An optional key that identifies the type of session. /// This can be used to distinguish between multiple application launch scenarios.
return System.Threading.Tasks.Task
        public static async Task RestoreAsync(String sessionBaseKey = null)
        {
            _sessionState = new Dictionary<String, Object>();

            try
            {
                // Get the input stream for the SessionState file
                StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(sessionStateFilename);
                using (IInputStream inStream = await file.OpenSequentialReadAsync())
                {
                    // Deserialize the Session State
                    DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary<string, object>), _knownTypes);
                    _sessionState = (Dictionary<string, object>)serializer.ReadObject(inStream.AsStreamForRead());
                }

                // Restore any registered frames to their saved state
                foreach (var weakFrameReference in _registeredFrames)
                {
                    Frame frame;
                    if (weakFrameReference.TryGetTarget(out frame) && (string)frame.GetValue(FrameSessionBaseKeyProperty) == sessionBaseKey)
                    {
                        frame.ClearValue(FrameSessionStateProperty);
                        RestoreFrameNavigationState(frame);
                    }
                }
            }
            catch (Exception e)
            {
                throw new SuspensionManagerException(e);
            }
        }