<commit_before>﻿namespace Slinqy.Test.Functional.Utilities.Polling
{
    using System;
    using System.Diagnostics;
    using System.Threading;

    /// <summary>
    /// Provides common polling functionality.
    /// </summary>
    internal static class Poll
    {
        /// <summary>
        /// Polls the specified function until a certain criteria is met.
        /// </summary>
        /// <typeparam name="T">Specifies the return type of the from function.</typeparam>
        /// <param name="from">Specifies the function to use to retrieve the value.</param>
        /// <param name="until">Specifies the function to use to test the value.</param>
        /// <param name="interval">Specifies how often to get the latest value via the from function.</param>
        /// <param name="maxPollDuration">Specifies the max amount of time to wait for the right value before giving up.</param>
        public
        static
        void
        Value<T>(
            Func<T>       from,
            Func<T, bool> until,
            TimeSpan      interval,
            TimeSpan      maxPollDuration)
        {
            var stopwatch = Stopwatch.StartNew();

            while (until(from()))
            {
                if (stopwatch.Elapsed > maxPollDuration)
                    throw new PollTimeoutException(maxPollDuration);

                Thread.Sleep(interval);
            }
        }
    }
}<commit_msg>Fix bug in polling logic.<commit_after>﻿namespace Slinqy.Test.Functional.Utilities.Polling
{
    using System;
    using System.Diagnostics;
    using System.Threading;

    /// <summary>
    /// Provides common polling functionality.
    /// </summary>
    internal static class Poll
    {
        /// <summary>
        /// Polls the specified function until a certain criteria is met.
        /// </summary>
        /// <typeparam name="T">Specifies the return type of the from function.</typeparam>
        /// <param name="from">Specifies the function to use to retrieve the value.</param>
        /// <param name="until">Specifies the function to use to test the value.</param>
        /// <param name="interval">Specifies how often to get the latest value via the from function.</param>
        /// <param name="maxPollDuration">Specifies the max amount of time to wait for the right value before giving up.</param>
        public
        static
        void
        Value<T>(
            Func<T>       from,
            Func<T, bool> until,
            TimeSpan      interval,
            TimeSpan      maxPollDuration)
        {
            var stopwatch = Stopwatch.StartNew();

            while (until(from()) == false)
            {
                if (stopwatch.Elapsed > maxPollDuration)
                    throw new PollTimeoutException(maxPollDuration);

                Thread.Sleep(interval);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.10226876090750436, 'fraction_numerical': 0.0, 'mean_word_length': 1.8208661417322836, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5932481', 'n_tokens_mistral': 729, 'n_tokens_neox': 710, 'n_words': 231}