private void OnPhilosopherEventRaised(object sender, PhilosopherEventArgs e) { if (e != null && e.Type == Philosopher.EventType.ReleaseRightFork) { Interlocked.Increment(ref _philosopherFinishedCount); } }
public static void OnForkGivenBack(object source, PhilosopherEventArgs args) { Application.MainLoop.Invoke(() => { forks[args.ForkId].ColorScheme = colorSchemes[5]; Application.Refresh(); }); }
public static void OnProgresStateChanged(object source, PhilosopherEventArgs args) { Application.MainLoop.Invoke(() => { progresState[args.PhilosopherId].Fraction = args.HungerLevel; Application.Refresh(); }); }
public static void OnLogAdded(object source, PhilosopherEventArgs args) { Application.MainLoop.Invoke(() => { logTextView.Text = args.Log + "\n" + logTextView.Text; logTextView.ReadOnly = true; Application.Refresh(); }); }
private static void Show(object sender, PhilosopherEventArgs args) { Console.Clear(); switch (args.State) { case PhilosopherClasses.Enums.PhilosopherState.ThinkingWithoutForks: Console.ForegroundColor = ConsoleColor.White; break; case PhilosopherClasses.Enums.PhilosopherState.ThinkingWithLeftFork: Console.ForegroundColor = ConsoleColor.Blue; break; case PhilosopherClasses.Enums.PhilosopherState.Eating: Console.ForegroundColor = ConsoleColor.Green; break; } Console.WriteLine("Philosopher № {0} ForkState - {1} State - {2}", args.Number, args.ForksState, args.State); }