Example #1
0
        public void Run()
        {
            Console.WriteLine("--Blackboard pattern--\n");

            const int problemCount = 25;

            var itemsOfInterest = new List <ItemOfInterest>();

            for (int i = 0; i < problemCount; i++)
            {
                itemsOfInterest.Add(new ItemOfInterest {
                    Name = (i + 1).ToString()
                });
            }

            var problems   = new BlackboardRepository(itemsOfInterest);
            var controller = new Controller(problems);

            var scientist   = new Thread(controller.ScientistWork);
            var economist   = new Thread(controller.EconomistWork);
            var philosopher = new Thread(controller.PhilosopherWork);

            scientist.Start();
            economist.Start();
            philosopher.Start();

            scientist.Join();
            economist.Join();
            philosopher.Join();

            Console.WriteLine();
        }
 public ControlShell(BlackboardRepository blackboard)
 {
     _blackboard = blackboard;
 }
Example #3
0
 public Controller(BlackboardRepository repository)
 {
     _controllShell = new ControlShell(repository);
 }