Esempio n. 1
0
        /// <summary>
        /// Wait for the progress notifications to complete.
        /// </summary>
        /// <param name="progressList">
        /// The list of progress notifications being updated by the Progress handler.
        /// </param>
        /// <param name="totalSize">The total size we should eventually see.</param>
        /// <returns>A task that will (optionally) delay.</returns>
        protected async Task WaitForProgressAsync(System.Collections.Concurrent.ConcurrentBag <long> progressBag, long totalSize)
        {
            for (var attempts = 0; attempts < 10; attempts++)
            {
                // ConcurrentBag.GetEnumerator() returns a snapshot in time; we can safely use linq queries
                if (progressBag.Count > 0 && progressBag.Max() >= totalSize)
                {
                    return;
                }

                // Wait for lingering progress events
                await Delay(500, 100).ConfigureAwait(false);
            }

            // TODO: #7077 - These are too flaky/noisy so I'm changing to Warn
            Assert.Warn("Progress notifications never completed!");
        }