Ejemplo n.º 1
0
        /// <summary>
        /// 取消注册子计时器,并重置其计数
        /// </summary>
        /// <param name="subTimer"></param>
        public static void UnregisterSubTimer(SubTimer subTimer)
        {
            if (subTimer == null)
            {
                throw new ArgumentNullException(nameof(subTimer));
            }

            subTimer.IsEnabled = false;

            lock (_timer)
            {
                _subTimers.Remove(subTimer);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 注册子计时器
        /// </summary>
        /// <param name="subTimer"></param>
        public static void RegisterSubTimer(SubTimer subTimer)
        {
            if (subTimer == null)
            {
                throw new ArgumentNullException(nameof(subTimer));
            }

            lock (_timer)
            {
                if (_subTimers.Contains(subTimer))
                {
                    throw new Exception("subTimer registered");
                }

                _subTimers.Add(subTimer);
            }
        }