/// <summary> /// Purge worker pool by removing all workers that are currently stopped (not working). /// <br /><br /> /// Returns amount of workers removed this way. /// </summary> /// <returns></returns> public int Purge() { int count = 0; foreach (T o in GetArray()) { if (null == o) { continue; } bool remove = false; if (o is Energy.Interface.IWorker) { Energy.Interface.IWorker w = o as Energy.Interface.IWorker; if (!w.Running) { remove = true; } } if (remove) { Remove(o); count++; } } return(count); }
public void Stop() { foreach (T o in GetArray()) { if (null == o) { continue; } if (o is Energy.Interface.IWorker) { Energy.Interface.IWorker w = o as Energy.Interface.IWorker; w.Stop(); } } }
public void Spawn() { try { T o = Activator.CreateInstance <T>(); _List.Add(o); if (o is Energy.Interface.IWorker) { Energy.Interface.IWorker worker = o as Energy.Interface.IWorker; worker.Start(); } } catch (MissingMethodException) { System.Diagnostics.Debug.WriteLine("Missing method for constructing new object for spawn"); } }
private bool GetRunning() { foreach (T o in GetArray()) { if (null == o) { continue; } if (o is Energy.Interface.IWorker) { Energy.Interface.IWorker w = o as Energy.Interface.IWorker; if (w.Running) { return(true); } } } return(false); }