Example #1
0
        public static void Main(string[] args)
        {
            var bus        = new AppBus();
            var alarmClock = new AlarmClock(bus);
            var startables = new List <IStartable> ();

            var importantManQueue = new QueuedHandler(new NarrowingHandler <Message, NeedToTakeAction>(new ImportantMan(bus)), "Important man");
            var monitorQueue      = new QueuedHandler(
                new RoundRobinWithLoadBalancing(
                    new[] {
                CreateMonitor(bus, startables, "Monitor q #01"),
                CreateMonitor(bus, startables, "Monitor q #02"),
                CreateMonitor(bus, startables, "Monitor q #03")
            }
                    ), "Monitor queues"
                );

            bus.Subscribe(alarmClock);
            bus.Subscribe(new WideningHandler <Message, NeedToTakeAction>(importantManQueue));
            bus.Subscribe(monitorQueue);

            startables.Add(alarmClock);
            startables.Add(monitorQueue);
            startables.Add(importantManQueue);

            startables.ForEach(s => s.Start());

            RunStatistics(startables);
            RunFakeSensors(bus);

            Console.ReadKey();
        }
Example #2
0
 static void RunFakeSensors(AppBus bus)
 {
     for (var ii = 0; ii < 10; ii++)
     {
         new TemperatureSensor(bus, ii.ToString()).Start();
     }
 }