public BackgroundUpdateListenerWorker(BackgroundUpdateListener updateListener)
 {
     this.updateListener       = updateListener;
     workerThread              = new Thread(doWork);
     workerThread.IsBackground = true;
     workerThread.Start();
 }
예제 #2
0
 /// <summary>
 /// Remove a listener from the full speed loop.
 /// </summary>
 /// <param name="listener">The listener to remove</param>
 public void removeBackgroundUpdateListener(String name, BackgroundUpdateListener listener)
 {
     try
     {
         UpdateListenerWithBackgrounding bgListenerWorker = multiThreadedWorkerListeners[name];
         bgListenerWorker.removeBackgroundListener(listener);
     }
     catch (KeyNotFoundException)
     {
         //This is ok, the foreground task may have been removed first
     }
 }
예제 #3
0
 /// <summary>
 /// Add a listener that will be updated as fast a possible by the loop.
 /// </summary>
 /// <param name="listener">The listener to add.</param>
 public void addBackgroundUpdateListener(String name, BackgroundUpdateListener listener)
 {
     try
     {
         UpdateListenerWithBackgrounding bgListenerWorker = multiThreadedWorkerListeners[name];
         bgListenerWorker.addBackgroundListener(listener);
     }
     catch (KeyNotFoundException)
     {
         Log.Warning("Could not find background worker supporting update named '{0}'. Be sure to add the update listeners that support background tasks before the background tasks. Listener will not update.", name);
     }
 }
        public void removeBackgroundListener(BackgroundUpdateListener listener)
        {
            BackgroundUpdateListenerWorker foundWorker = null;

            foreach (BackgroundUpdateListenerWorker worker in workers)
            {
                if (worker.UpdateListener == listener)
                {
                    foundWorker = worker;
                    break;
                }
            }
            if (foundWorker != null)
            {
                workers.Remove(foundWorker);
                foundWorker.Dispose();
            }
        }
 public void addBackgroundListener(BackgroundUpdateListener backgroundUpdate)
 {
     workers.Add(new BackgroundUpdateListenerWorker(backgroundUpdate));
 }