Exemple #1
0
 public TimerEx(String name, bool isBackground)
 {
     if (name == null)
     {
         throw new NullReferenceException("name is null");
     }
     this.impl     = new TimerImpl(name, isBackground);
     this.disposal = new DisposeHelper(impl);
 }
Exemple #2
0
        public Timer periodic(TimeSpan duration, Action callback)
        {
            var timer = new TimerImpl(duration, callback, periodic: true);

            lock (this._queue) {
                this._queue.enqueue(timer);
            }

            return(timer);
        }
Exemple #3
0
        public Timer run(TimeSpan duration, Action callback)
        {
            var timer = new TimerImpl(duration, callback);

            lock (this._queue) {
                this._queue.enqueue(timer);
            }

            return(timer);
        }
Exemple #4
0
        public Timer runInMain(Action callback)
        {
            var timer = new TimerImpl(callback);

            lock (this._queue) {
                this._queue.enqueue(timer);
            }

            return(timer);
        }
Exemple #5
0
 protected override IDisposable Run(IObserver <long> observer, IDisposable cancel, Action <IDisposable> setSink)
 {
     if (_period.HasValue)
     {
         var sink = new TimerImpl(this, observer, cancel);
         setSink(sink);
         return(sink.Run());
     }
     else
     {
         var sink = new _(this, observer, cancel);
         setSink(sink);
         return(sink.Run());
     }
 }
Exemple #6
0
 public DisposeHelper(TimerImpl impl)
 {
     this.impl = impl;
 }