public static void WaitForQueueToEmpty(BackgroundHttpRequester requester) { var time = new Stopwatch(); time.Start(); while (requester.QueueCount != 0 && time.Elapsed < timeout) Task.Delay(TimeSpan.FromMilliseconds(100)).Wait(); }
/// <summary> /// Start the requester with any unsent URIs from the last application run. /// </summary> /// <param name="uploadInterval">How often to send URIs to analytics.</param> /// <returns>Task that completes when the requester is ready.</returns> private static async Task StartRequesterAsync(TimeSpan uploadInterval) { requester = new BackgroundHttpRequester(PreprocessHttpRequest); var previousRequests = await LocalFolderContractSerializer<List<Uri>>.RestoreAsync(RequestQueueFileName); requester.Start(uploadInterval, previousRequests); }