Ejemplo n.º 1
0
            /// <summary>Creates a new instance of DateTimePrecise.</summary>
            /// <remarks>
            /// A large value of synchronizePeriodSeconds may cause arithmetic overthrow
            /// exceptions to be thrown. A small value may cause the time to be unstable.
            /// A good value is 10.
            /// </remarks>
            /// <param name="synchronizePeriodSeconds">The number of seconds after which the class will synchronize itself with the system clock.</param>
            public PreciseTime(long synchronizePeriodSeconds)
            {
                m_stopwatch = Stopwatch.StartNew();
                m_stopwatch.Start();

                DateTime t = DateTime.UtcNow;

                m_timeState = new ImmutableTimeState(t, t, m_stopwatch.ElapsedTicks, Stopwatch.Frequency);

                m_synchronizePeriodStopwatchTicks = synchronizePeriodSeconds * Stopwatch.Frequency;
                m_synchronizePeriodClockTicks     = synchronizePeriodSeconds * Ticks.PerSecond;
            }
Ejemplo n.º 2
0
            /// <summary>Creates a new instance of DateTimePrecise.</summary>
            /// <remarks>
            /// A large value of synchronizePeriodSeconds may cause arithmetic overthrow
            /// exceptions to be thrown. A small value may cause the time to be unstable.
            /// A good value is 10.
            /// </remarks>
            /// <param name="synchronizePeriodSeconds">The number of seconds after which the class will synchronize itself with the system clock.</param>
            public PreciseTime(long synchronizePeriodSeconds)
            {
                m_stopwatch = Stopwatch.StartNew();
                m_stopwatch.Start();

                DateTime t = DateTime.UtcNow;
                m_timeState = new ImmutableTimeState(t, t, m_stopwatch.ElapsedTicks, Stopwatch.Frequency);

                m_synchronizePeriodStopwatchTicks = synchronizePeriodSeconds * Stopwatch.Frequency;
                m_synchronizePeriodClockTicks = synchronizePeriodSeconds * Ticks.PerSecond;
            }