コード例 #1
0
        static void Main(string[] args)
        {
            var mec = new Mecanico();

            PoolDeTareas pool = new PoolDeTareas();

            mec.On_Task_Start += (string taskName) => { Console.WriteLine("----------------------"); Console.WriteLine($"{ taskName } inicio de la tarea"); };
            mec.on_start      += (string task) => { };
            mec.On_Task_end   += (string taskName) => { Console.WriteLine($"{ taskName } Fin de la tarea"); Console.WriteLine("----------------------"); };

            var pin = new Pintor();

            pin.On_Task_Start += OnStart;
            pin.On_Task_end   += OnEnd;

            for (int i = 1; i < 50; i++)
            {
                pool.TomarTarea(mec);
                mec.RealizarTarea();

                pool.TomarTarea(pin);
                pin.RealizarTarea();
            }
            Console.WriteLine("Fin de proceso");
            Console.ReadKey();
        }
コード例 #2
0
 public void TomarTarea(Mecanico m)
 {
     if (autoAReparar.Any())
     {
         m.RecibirTarea(autoAReparar.FirstOrDefault());
         autoAReparar.Remove(autoAReparar.FirstOrDefault());
     }
 }