Exemple #1
0
            public SharedTimerInstance(SharedTimerScheduler parentTimer, int interval)
            {
                if (interval <= 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(interval));
                }

                m_parentTimer          = parentTimer ?? throw new ArgumentNullException(nameof(parentTimer));
                m_additionalQueueItems = new ConcurrentQueue <WeakAction <DateTime> >();
                m_syncRunning          = new object();
                m_syncStats            = new object();
                m_interval             = interval;
                m_callbacks            = new LinkedList <WeakAction <DateTime> >();
                m_timer = new Timer(Callback, null, interval, interval);
            }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SharedTimer"/>.
        /// </summary>
        /// <param name="scheduler">The scheduler to use.</param>
        /// <param name="interval">The interval of the timer, default is 100.</param>
        internal SharedTimer(SharedTimerScheduler scheduler, int interval = 100)
        {
            if (scheduler == null)
            {
                throw new ArgumentNullException(nameof(scheduler));
            }

            if (scheduler.IsDisposed)
            {
                throw new ArgumentException("Scheduler has been disposed", nameof(scheduler));
            }

            if (interval <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(interval));
            }

            m_scheduler = scheduler;
            m_interval  = interval;
            m_enabled   = false;
            m_autoReset = true;
            m_callback  = TimerCallback;
            m_scheduler = scheduler;
        }