예제 #1
0
        static void Main(string[] args)
        {
            Logger.InitLogger();
            var pointProducers = new IPointProducer[]
            { new Produce2XY(), new ProduceNotSimpleCoords(), new ProduceXYYYLessThan500() };

            var client = new Client {
                Name = "Red"
            };

            pointProducers[1].OnPointProduced += client.OnPointReceived;
            foreach (var producer in pointProducers)
            {
                Task.Run(() => producer.Run(x => Logger.Log.Info($"{producer.GetType().Name} produced a point {x}")));
            }
            while (true)
            {
                if (Console.ReadKey().Key != ConsoleKey.Escape)
                {
                    continue;
                }
                foreach (var producer in pointProducers)
                {
                    producer.IsContinue = false;
                }
                break;
            }
        }
예제 #2
0
 public void Add(IPointProducer producer, char cancelKey)
 {
     _cancelers.Add(cancelKey, () => { producer.IsContinue = false; });
 }
예제 #3
0
 public void StartListenProducer(IPointProducer producer)
 {
     producer.OnPointProduced += PointProducedHandler;
 }