System.Net.TimerThread.IsTickBetween C# (CSharp) Method

IsTickBetween() private static method

Helper for deciding whether a given TickCount is before or after a given expiration tick count assuming that it can't be before a given starting TickCount.

private static IsTickBetween ( int start, int end, int comparand ) : bool
start int
end int
comparand int
return bool
        private static bool IsTickBetween(int start, int end, int comparand)
        {
            // Assumes that if start and end are equal, they are the same time.
            // Assumes that if the comparand and start are equal, no time has passed,
            // and that if the comparand and end are equal, end has occurred.
            return ((start <= comparand) == (end <= comparand)) != (start <= end);
        }
    }

Usage Example

示例#1
0
 internal bool Fire()
 {
     if (this.m_TimerState == TimerState.Ready)
     {
         int tickCount = Environment.TickCount;
         if (TimerThread.IsTickBetween(base.StartTime, base.Expiration, tickCount))
         {
             return(false);
         }
         bool flag = false;
         lock (this.m_QueueLock)
         {
             if (this.m_TimerState == TimerState.Ready)
             {
                 this.m_TimerState = TimerState.Fired;
                 this.Next.Prev    = this.Prev;
                 this.Prev.Next    = this.Next;
                 this.Next         = null;
                 this.Prev         = null;
                 flag = this.m_Callback != null;
             }
         }
         if (flag)
         {
             try
             {
                 TimerThread.Callback callback = this.m_Callback;
                 object context = this.m_Context;
                 this.m_Callback = null;
                 this.m_Context  = null;
                 callback(this, tickCount, context);
             }
             catch (Exception exception)
             {
                 if (NclUtilities.IsFatal(exception))
                 {
                     throw;
                 }
                 if (Logging.On)
                 {
                     Logging.PrintError(Logging.Web, "TimerThreadTimer#" + base.StartTime.ToString(NumberFormatInfo.InvariantInfo) + "::Fire() - " + SR.GetString("net_log_exception_in_callback", new object[] { exception }));
                 }
             }
         }
     }
     return(true);
 }