Esempio n. 1
0
        private WeakAction <DateTime> RegisterCallback(int interval, WeakAction <DateTime> weakAction)
        {
            if ((object)weakAction == null)
            {
                throw new ArgumentNullException(nameof(weakAction));
            }

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

            if (m_disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            lock (m_syncRoot)
            {
                if (m_disposed)
                {
                    throw new ObjectDisposedException(GetType().FullName);
                }

                SharedTimerInstance instance;

                if (!m_schedulesByInterval.TryGetValue(interval, out instance))
                {
                    instance = new SharedTimerInstance(this, interval);
                    m_schedulesByInterval.Add(interval, instance);
                }

                return(instance.RegisterCallback(weakAction));
            }
        }
        private WeakAction<DateTime> RegisterCallback(int interval, WeakAction<DateTime> weakAction)
        {
            if ((object)weakAction == null)
                throw new ArgumentNullException(nameof(weakAction));

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

            if (m_disposed)
                throw new ObjectDisposedException(GetType().FullName);

            lock (m_syncRoot)
            {
                if (m_disposed)
                    throw new ObjectDisposedException(GetType().FullName);

                SharedTimerInstance instance;

                if (!m_schedulesByInterval.TryGetValue(interval, out instance))
                {
                    instance = new SharedTimerInstance(this, interval);
                    m_schedulesByInterval.Add(interval, instance);
                }

                return instance.RegisterCallback(weakAction);
            }
        }