Beispiel #1
0
        /// <summary>
        /// Start the requester with any unsent URIs from the last application run.
        /// </summary>
        /// <returns>Task that completes when the requester is ready.</returns>
        private static async Task StartRequesterAsync()
        {
            requester = new BackgroundHttpClientRequester(PreprocessHttpRequest, IsInternetAvailable);
            var previousRequests = await LocalFolderContractSerializer <List <Uri> > .RestoreAsync(RequestQueueFileName);

            requester.Start(lastUploadInterval, previousRequests);
        }
Beispiel #2
0
        /// <summary>
        /// Suspend the requester and preserve any unsent URIs.
        /// </summary>
        /// <returns>Task that completes when the requester has been suspended.</returns>
        private static async Task SuspendRequesterAsync()
        {
            var recentRequestsToPersist = new List <Uri>();

            if (requester.IsStarted)
            {
                var pendingRequests = await requester.StopAsync();

                recentRequestsToPersist = pendingRequests.Skip(pendingRequests.Count - MaximumRequestsToPersist).ToList();
            }
            await LocalFolderContractSerializer <List <Uri> > .SaveAsync(recentRequestsToPersist, RequestQueueFileName);

            await SaveSessionState(sessionManager.GetState());
        }
Beispiel #3
0
 /// <summary>
 /// Save the session state to preserve state between application launches.
 /// </summary>
 /// <returns>Task that completes when the session state has been saved.</returns>
 protected override async Task Save <T>(T data, string name)
 {
     await LocalFolderContractSerializer <T> .SaveAsync(data, name);
 }
Beispiel #4
0
 /// <summary>
 /// Load the session state from storage if it exists, null if it does not.
 /// </summary>
 /// <returns>Task that completes when the SessionState is available.</returns>
 protected override async Task <T> Load <T>(string name)
 {
     return(await LocalFolderContractSerializer <T> .RestoreAsync(name));
 }
Beispiel #5
0
 /// <summary>
 /// Save the session state to preserve state between application launches.
 /// </summary>
 /// <returns>Task that completes when the session state has been saved.</returns>
 private static async Task SaveSessionState(SessionState sessionState)
 {
     await LocalFolderContractSerializer <SessionState> .SaveAsync(sessionState, SessionStateFileName);
 }
Beispiel #6
0
 /// <summary>
 /// Load the session state from storage if it exists, null if it does not.
 /// </summary>
 /// <returns>Task that completes when the SessionState is available.</returns>
 private static async Task <SessionState> LoadSessionState()
 {
     return(await LocalFolderContractSerializer <SessionState> .RestoreAsync(SessionStateFileName));
 }