コード例 #1
0
ファイル: PrecisionTimer.cs プロジェクト: ajstadlin/GridTrak
        /// Creates a new instance of DateTimePrecise.
        /// 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.
        /// synchronizePeriodSeconds = The number of seconds after which the
        /// DateTimePrecise will synchronize itself with the system clock.
        public DateTimePrecise(long synchronizePeriodSeconds)
        {
            Stopwatch = Stopwatch.StartNew();
              this.Stopwatch.Start();

              DateTime t = DateTime.UtcNow;
              _immutable = new DateTimePreciseSafeImmutable(t, t, Stopwatch.ElapsedTicks, Stopwatch.Frequency);

              _synchronizePeriodSeconds = synchronizePeriodSeconds;
              _synchronizePeriodStopwatchTicks = synchronizePeriodSeconds * Stopwatch.Frequency;
              _synchronizePeriodClockTicks = synchronizePeriodSeconds * _clockTickFrequency;
        }
コード例 #2
0
        /// Creates a new instance of DateTimePrecise.
        /// 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.
        /// synchronizePeriodSeconds = The number of seconds after which the
        /// DateTimePrecise will synchronize itself with the system clock.
        public DateTimePrecise(long synchronizePeriodSeconds)
        {
            Stopwatch = Stopwatch.StartNew();
            this.Stopwatch.Start();

            DateTime t = DateTime.UtcNow;

            _immutable = new DateTimePreciseSafeImmutable(t, t, Stopwatch.ElapsedTicks, Stopwatch.Frequency);

            _synchronizePeriodSeconds        = synchronizePeriodSeconds;
            _synchronizePeriodStopwatchTicks = synchronizePeriodSeconds * Stopwatch.Frequency;
            _synchronizePeriodClockTicks     = synchronizePeriodSeconds * _clockTickFrequency;
        }