Beispiel #1
0
        /// <summary>
        /// Creates and starts a new IterationWaiter with specified iteration time.
        /// Equivalent to creating an instance using constructor and calling Start().
        /// </summary>
        /// <param name="iterationTime">Desired minimum iteration time in milliseconds.</param>
        /// <returns>Created IterationWaiter instance.</returns>
        public static IterationWaiter StartNew(int iterationTime)
        {
            var waiter = new IterationWaiter(iterationTime);

            waiter.Start();
            return(waiter);
        }
Beispiel #2
0
        /// <summary>
        /// Executes the <see cref="RunIteration"/> method periodically until stopped.
        /// The minimum time between the executions is <see cref="IterationTime"/>.
        /// </summary>
        private void Execute()
        {
            var waiter = new IterationWaiter(_iterationTime);

            while (_isRunning)
            {
                waiter.Start();

                try
                {
                    RunIteration();
                }
                catch (Exception ex)
                {
                    OnRunIterationException(ex);
                }

                waiter.Wait();
            }
        }