/// <summary> /// Gives bagage to the sorting system bagageBuffer and removes bagage from desk bagageBuffer /// </summary> public void GiveBagageToSorter() { Bagage bagage; while (true) { lock (_lock) { for (int i = 0; i < desks.Length; i++) { for (int j = 0; j < desks[i].bagageBuffer.Length; j++) { if (desks[i].bagageBuffer[j] != null) { bagage = desks[i].bagageBuffer[j]; SortingSystem.GetSortingSystem().SortBagage(bagage, terminals); bagageSorted?.Invoke(desks[i], new EventArgs()); desks[i].bagageBuffer[j] = null; Monitor.PulseAll(_lock); } else { Monitor.Wait(_lock); } } } } } }
public static SortingSystem GetSortingSystem() { lock (_lock) { if (instance == null) { instance = new SortingSystem(); } return(instance); } }