Esempio n. 1
0
        /// <summary>
        /// This method stops the internal stopwatch, generates a response, then resets and starts the internal stopwatch
        /// </summary>
        /// <param name="iteration"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public TickerTimeTable Reset(int iteration, int total)
        {
            // Define our structure
            TickerTimeTable response = new TickerTimeTable();

            // Stop the timer
            _stopwatch.Stop();
            // Set the elapsed time into the response
            response.Elapsed = _stopwatch.Elapsed;
            // Set the iteration into the response
            response.Iteration = iteration;
            // Set the iteration count into the response
            response.IterationTotal = total;
            // Set the time remaining into the response
            response.Remaining =
                TimeSpan.FromMilliseconds((_stopwatch.ElapsedMilliseconds / iteration) * (total - iteration));
            // Set the total into the response
            response.Total = response.Elapsed.Add(response.Remaining);
            // Reset the timer
            _stopwatch.Reset();
            // Start the timer
            _stopwatch.Start();
            // We're done, send the response
            return(response);
        }
Esempio n. 2
0
        /// <summary>
        /// This method stops the internal stopwatch then generates and returns a response
        /// </summary>
        /// <returns></returns>
        public TickerTimeTable Halt()
        {
            // Define our structure
            TickerTimeTable response = new TickerTimeTable();

            // Stop the timer
            _stopwatch.Stop();
            // Set the elapsed time into the response
            response.Elapsed = _stopwatch.Elapsed;
            // We're done, send the response
            return(response);
        }