private void WriteToQueue(string value, bool isNewLine) { if (value != null) { if (isNewLine) { value = value + NewLine; } ItemQueue.Enqueue(value); _queued?.Invoke(this, EventArgs.Empty); } }
public void Start() { if (!IsRunning) { IsRunning = true; new System.Threading.Thread(() => { while (true) { bool check = false; bool condition = false; lock (__queuelock) { condition = ItemQueue.Count < BufferingSize; } if (condition) { var item = Source.Congruence(); Get(ref item); lock (__queuelock) { ItemQueue.Enqueue(item); } check = true; } if (!check) { System.Threading.Thread.Sleep(1); } else { //Console.WriteLine($"Reader : Load-> c/{ItemQueue.Count}"); } } }).Start(); } if (null == gcThread) { gcThread = new System.Threading.Thread(() => { while (true) { GC.Collect(); System.Threading.Thread.Sleep(1000); } }); gcThread.Start(); } }
public void BeginStartup() { if (Show != null) { // Sort the items Show.Items.Sort((item1, item2) => item1.ItemOrder.CompareTo(item2.ItemOrder)); foreach (Shows.ShowItem item in Show.GetItems(Shows.ShowItemType.Startup)) { ItemQueue.Enqueue(item); } ExecuteNextStartupItem(); } }
public void BeginSequential() { ScheduleExecutor.Logging.Info("BeginSequential"); if (Show != null && State == StateType.Running) { State = StateType.Running; foreach (Shows.ShowItem item in Show.GetItems(Shows.ShowItemType.Sequential)) { ScheduleExecutor.Logging.Info("BeginSequential: Enqueue:" + item.Name); ItemQueue.Enqueue(item); } if (ItemQueue.Any()) { ExecuteNextSequentialItem(); } } }
public void BeginShutdown() { if (Show != null) { ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting shutdown"); StopBackground(); StopSequential(); ItemQueue.Clear(); State = StateType.Shutdown; foreach (ShowItem item in Show.GetItems(Shows.ShowItemType.Shutdown)) { LogScheduleInfoEntry(string.Format("BeginShutdown: Enqueue: {0}", item.Name)); ItemQueue.Enqueue(item); } ExecuteNextShutdownItem(); } }
public void BeginShutdown() { if (Show != null) { ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting shutdown"); StopBackground(); ItemQueue.Clear(); State = StateType.Shutdown; foreach (Shows.ShowItem item in Show.GetItems(Shows.ShowItemType.Shutdown)) { ScheduleExecutor.Logging.Info("BeginShutdown: Enqueue: " + item.Name); ItemQueue.Enqueue(item); } ExecuteNextShutdownItem(); } }
public void BeginSequential() { LogScheduleInfoEntry("BeginSequential"); if (Show != null && State == StateType.Running) { State = StateType.Running; foreach (ShowItem item in Show.GetItems(ShowItemType.Sequential)) { LogScheduleInfoEntry("BeginSequential: Enqueue:" + item.Name); ItemQueue.Enqueue(item); } if (ItemQueue.Any()) { ExecuteNextSequentialItem(); } else { LogScheduleInfoEntry("BeginSequential: Nothing in queue."); } } }