コード例 #1
0
 private void OnPhilosopherEventRaised(object sender, PhilosopherEventArgs e)
 {
     if (e != null && e.Type == Philosopher.EventType.ReleaseRightFork)
     {
         Interlocked.Increment(ref _philosopherFinishedCount);
     }
 }
コード例 #2
0
ファイル: GUI.cs プロジェクト: MichalSurmacki/SO2_Projekt
 public static void OnForkGivenBack(object source, PhilosopherEventArgs args)
 {
     Application.MainLoop.Invoke(() =>
     {
         forks[args.ForkId].ColorScheme = colorSchemes[5];
         Application.Refresh();
     });
 }
コード例 #3
0
ファイル: GUI.cs プロジェクト: MichalSurmacki/SO2_Projekt
 public static void OnProgresStateChanged(object source, PhilosopherEventArgs args)
 {
     Application.MainLoop.Invoke(() =>
     {
         progresState[args.PhilosopherId].Fraction = args.HungerLevel;
         Application.Refresh();
     });
 }
コード例 #4
0
ファイル: GUI.cs プロジェクト: MichalSurmacki/SO2_Projekt
 public static void OnLogAdded(object source, PhilosopherEventArgs args)
 {
     Application.MainLoop.Invoke(() =>
     {
         logTextView.Text     = args.Log + "\n" + logTextView.Text;
         logTextView.ReadOnly = true;
         Application.Refresh();
     });
 }
コード例 #5
0
        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);
        }