Exemple #1
0
        public bool TimedOut()
        {
            if (_endTick.GetInt64Value() == 0)
            {
                return(true);
            }

            Tick currentTick = _os.GetTickManager().GetTick();

            return(currentTick >= _endTick);
        }
        public TimeSpan ConvertToTimespan(Tick tick)
        {
            // Get the tick value.
            long ticks = tick.GetInt64Value();

            // Get the tick frequency.
            long tickFreq = GetTickFrequency();

            Assert.True(tickFreq < MaxTickFrequency);

            // Clamp tick to range.
            if (ticks > GetMaxTick())
            {
                return(TimeSpan.FromNanoSeconds(long.MaxValue));
            }
            else if (ticks < -GetMaxTick())
            {
                return(TimeSpan.FromNanoSeconds(long.MinValue));
            }
            else
            {
                // Convert to timespan.
                long nanoSecondsPerSecond = TimeSpan.FromSeconds(1).GetNanoSeconds();
                long seconds = ticks / tickFreq;
                long frac    = ticks % tickFreq;

                TimeSpan ts = TimeSpan.FromSeconds(seconds) +
                              TimeSpan.FromNanoSeconds(frac * nanoSecondsPerSecond / tickFreq);

                Assert.True(!(ticks > 0 && ts < default(TimeSpan) || ticks <0 && ts> default(TimeSpan)));

                return(ts);
            }
        }