Beispiel #1
0
        public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, TimerCallback callback)
        {
            Timer t = new DelayCallTimer(delay, interval, count, callback);

            t.Start();

            return(t);
        }
Beispiel #2
0
        public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, TimerCallback callback)
        {
            Timer t = new DelayCallTimer(delay, interval, count, callback);

            t.Priority = ComputePriority(count == 1 ? delay : interval);
            t.Start();

            return(t);
        }
Beispiel #3
0
        private static void ReturnToPool(int amount, DelayCallTimer head, DelayCallTimer tail)
        {
            tail.Attach(_poolHead);
            _poolHead   = head;
            _poolCount += amount;
#if DEBUG_TIMERS
            logger.Information("Returning to pool. ({Count} / {Capacity})", _poolCount, _poolCapacity);
#endif
        }
Beispiel #4
0
        public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback)
        {
            DelayCallTimer t = DelayCallTimer.GetTimer(delay, interval, count, callback);

            t._returnOnDetach = true;
            t.Start();

#if DEBUG_TIMERS
            DelayCallTimer._stackTraces[t.GetHashCode()] = new StackTrace().ToString();
#endif
        }
Beispiel #5
0
        public static DelayCallTimer DelayCall(TimeSpan delay, TimeSpan interval, int count, Action callback)
        {
            DelayCallTimer t = new DelayCallTimer(delay, interval, count, callback);

            t.Start();
#if DEBUG_TIMERS
            t._allowFinalization = true;
#endif

            return(t);
        }
Beispiel #6
0
        public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback, out TimerExecutionToken token)
        {
            DelayCallTimer t = DelayCallTimer.GetTimer(delay, interval, count, callback);

            t.Start();

#if DEBUG_TIMERS
            DelayCallTimer._stackTraces[t.GetHashCode()] = new StackTrace().ToString();
#endif
            token = new TimerExecutionToken(t);
        }
Beispiel #7
0
        public void CallbackTest()
        {
            TimerPriority     processPriority  = new TimerPriority();                                                                         // TODO: 初始化为适当的值
            TimeSpan          delayTimeSpan    = new TimeSpan();                                                                              // TODO: 初始化为适当的值
            TimeSpan          intervalTimeSpan = new TimeSpan();                                                                              // TODO: 初始化为适当的值
            long              iCount           = 0;                                                                                           // TODO: 初始化为适当的值
            TimeSliceCallback timerCallback    = null;                                                                                        // TODO: 初始化为适当的值
            DelayCallTimer    target           = new DelayCallTimer(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerCallback); // TODO: 初始化为适当的值
            TimeSliceCallback actual;

            actual = target.Callback;
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #8
0
 public static Server.Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, Server.TimerCallback callback)
 {
     Server.Timer timer1 = new DelayCallTimer(delay, interval, count, callback);
     if (count == 1)
     {
         timer1.Priority = Server.Timer.ComputePriority(delay);
     }
     else
     {
         timer1.Priority = Server.Timer.ComputePriority(interval);
     }
     timer1.Start();
     return(timer1);
 }
Beispiel #9
0
        private static DelayCallTimer GetFromPool()
        {
            if (_poolHead == null)
            {
                return(null);
            }

            var timer = _poolHead;

            _poolHead = _poolHead._nextTimer as DelayCallTimer;
            timer.Detach();
            _poolCount--;

            return(timer);
        }
Beispiel #10
0
        public void ToStringTest()
        {
            TimerPriority     processPriority  = new TimerPriority();                                                                         // TODO: 初始化为适当的值
            TimeSpan          delayTimeSpan    = new TimeSpan();                                                                              // TODO: 初始化为适当的值
            TimeSpan          intervalTimeSpan = new TimeSpan();                                                                              // TODO: 初始化为适当的值
            long              iCount           = 0;                                                                                           // TODO: 初始化为适当的值
            TimeSliceCallback timerCallback    = null;                                                                                        // TODO: 初始化为适当的值
            DelayCallTimer    target           = new DelayCallTimer(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerCallback); // TODO: 初始化为适当的值
            string            expected         = string.Empty;                                                                                // TODO: 初始化为适当的值
            string            actual;

            actual = target.ToString();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #11
0
        internal static void RefillPool(int amount, out DelayCallTimer head, out DelayCallTimer tail)
        {
#if DEBUG_TIMERS
            logger.Information("Filling pool with {Amount} timers.", amount);
#endif

            head = null;
            tail = null;

            for (var i = 0; i < amount; i++)
            {
                var timer = new DelayCallTimer(TimeSpan.Zero, TimeSpan.Zero, 0, null);
                timer.Attach(head);

                if (i == 0)
                {
                    tail = timer;
                }

                head = timer;
            }
        }
		public static Timer DelayCall( TimeSpan delay, TimeSpan interval, int count, TimerCallback callback )
		{
			Timer t = new DelayCallTimer( delay, interval, count, callback );

			if ( count == 1 )
				t.Priority = ComputePriority( delay );
			else
				t.Priority = ComputePriority( interval );

			t.Start();

			return t;
		}