/// <summary>
 /// Detaches timer consumer.
 /// </summary>
 /// <param name="iTimerConsumer">Timer consumer to attach.</param>
 public static void Detach(ITimerConsumer iTimerConsumer)
 {
     lock(_clients)
     {
         _clients.Remove(new WeakReference(iTimerConsumer));
     }
 }
 /// <summary>
 /// Attaches timer consumer.
 /// </summary>
 /// <param name="iTimerConsumer">Timer consumer to attach.</param>
 public static void Attach(ITimerConsumer iTimerConsumer)
 {
     lock(_clients)
     {
         _clients.Add(new WeakReference(iTimerConsumer));
     }
 }
예제 #3
0
 /// <summary>
 /// Attaches timer consumer.
 /// </summary>
 /// <param name="iTimerConsumer">Timer consumer to attach.</param>
 public static void Attach(ITimerConsumer iTimerConsumer)
 {
     lock (_clients)
     {
         _clients.Add(new WeakReference(iTimerConsumer));
     }
 }
예제 #4
0
 /// <summary>
 /// Detaches timer consumer.
 /// </summary>
 /// <param name="iTimerConsumer">Timer consumer to attach.</param>
 public static void Detach(ITimerConsumer iTimerConsumer)
 {
     lock (_clients)
     {
         _clients.Remove(new WeakReference(iTimerConsumer));
     }
 }
예제 #5
0
        /// <summary>
        /// Is executed every 10 seconds.
        /// </summary>
        /// <param name="state">Useless parameter.</param>
        public static void TimerCallback(object state)
        {
            lock (_clients)
            {
                for (int i = 0; i < _clients.Count;)
                {
                    ITimerConsumer iTimerConsumer = null;

                    WeakReference weakReference = _clients[i] as WeakReference;
                    if (weakReference != null)
                    {
                        iTimerConsumer = weakReference.Target as ITimerConsumer;
                    }
                    if (iTimerConsumer == null)
                    {
                        _clients.RemoveAt(i);
                        continue;
                    }

                    // safe call
                    try
                    {
                        iTimerConsumer.TimerCallback();
                    }
                    catch (Exception)
                    {
                    }

                    i++;
                }
            }
        }