private OneShotTimer(Action callback, long msTime)
    {
        _callback = callback;
        dynamic timer = new Threading.Timer(TimerProc);

        timer.Change(msTime, Threading.Timeout.Infinite);
    }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SensorServiceBase&lt;TValueInterface, TEventArgs&gt;"/> class.
        /// </summary>
        protected SensorServiceBase()
        {
            _timer = new Threading.Timer(OnTimerTick, null, _defaultInterval, _defaultInterval);

            ExpectedValues = new Queue <SensorTestData <TValueInterface> >();

            IsSupported = true;
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocationService"/> class.
        /// </summary>
        public LocationService()
        {
            var interval = TimeSpan.FromSeconds(1);

            _timer = new Threading.Timer(OnTimerTick, null, interval, interval);


            ExpectedLocations = new Queue <LocationTestData>();
        }
Example #4
0
        public IHyperTimer StopIn(TimeSpan dueTime)
        {
            if (dueTime < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("dueTime");
            }

            _stopScheduler = new Threading.Timer(state => Stop(), null, dueTime, Timeout.InfiniteTimeSpan);

            return(this);
        }
Example #5
0
        /// <summary>
        ///    <para>Disposes of the resources (other than memory) used by
        ///       the <see cref='System.Timers.Timer'/>.</para>
        /// </summary>
        public void Close()
        {
            _initializing  = false;
            _delayedEnable = false;
            _enabled       = false;

            if (_timer != null)
            {
                _timer.Dispose();
                _timer = null;
            }
        }
Example #6
0
        public IHyperTimer StopAt(DateTime stopTime)
        {
            DateTime now = DateTimeHelper.PreciseCurrentLocalTime;

            if (stopTime <= now)
            {
                throw new ArgumentOutOfRangeException("stopTime");
            }

            _stopScheduler = new Threading.Timer(state => Stop(), null, stopTime - now, Timeout.InfiniteTimeSpan);

            return(this);
        }
Example #7
0
        public IHyperTimer StopAt(DateTime stopTime)
        {
            DateTime now = DateTimeHelper.PreciseCurrentLocalTime;

            if (stopTime <= now)
            {
                throw new ArgumentOutOfRangeException("stopTime");
            }

            _stopScheduler = new Threading.Timer(state => Stop(), null, stopTime - now, Timeout.InfiniteTimeSpan);

            return this;
        }
Example #8
0
        public IHyperTimer StopIn(TimeSpan dueTime)
        {
            if (dueTime < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("dueTime");
            }

            _stopScheduler = new Threading.Timer(state => Stop(), null, dueTime, Timeout.InfiniteTimeSpan);

            return this;
        }
Example #9
0
        /// <summary>
        ///    <para>Disposes of the resources (other than memory) used by
        ///       the <see cref='System.Timers.Timer'/>.</para>
        /// </summary>
        public void Close()
        {
            _initializing = false;
            _delayedEnable = false;
            _enabled = false;

            if (_timer != null)
            {
                _timer.Dispose();
                _timer = null;
            }
        }