Exemple #1
0
        /// <summary>
        /// Handles all ThreadWorkers based on their state
        /// </summary>
        private void UpdateWorkers()
        {
            ThreadWorker[] keys = Workers.Keys.ToArray();
            for (int i = keys.Length - 1; i >= 0; i--)
            {
                ThreadWorker worker = keys[i];
                switch (worker.State)
                {
                case ThreadWorker.WorkerState.Running:
                    worker.OnUpdateWorker.Invoke();
                    break;

                case ThreadWorker.WorkerState.Closed:
                    worker.OnCloseWorker.Invoke();
                    Workers.Remove(worker);
                    break;

                case ThreadWorker.WorkerState.Error:
                    worker.OnErrorWorker.Invoke();
                    Workers.Remove(worker);
                    break;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Checks if a ThreadWorker is currently being handled by the dispatcher
 /// </summary>
 /// <param name="worker">ThreadWorker to check</param>
 /// <returns>true or false if the thread is in the dispatcher</returns>
 public static bool ContainsThreadWorker(ThreadWorker worker)
 {
     EnsureInstantiated();
     return(Workers.ContainsKey(worker));
 }