Ejemplo n.º 1
0
        public static void LucyWorker()
        {
            RobotLucy lucy = new RobotLucy();

            while (true)
            {
                if (filling <= 250 || flavor <= 10 || topping <= 100)
                {
                    outOfSomething = true;
                    continue;
                }
                outOfSomething = false;
                areBelt.Set();
                areLucy.WaitOne();
                lock (obj)
                {
                    filling -= lucy.getFilling();
                    Console.WriteLine("filling = {0} gr ", filling);
                }
                lock (obj)
                {
                    flavor -= lucy.getFlavor();
                    Console.WriteLine("flavor = {0} gr ", flavor);
                }
                lock (obj)
                {
                    topping -= lucy.getTopping();
                    Console.WriteLine("topping = {0} gr ", topping);
                }
            }
        }
Ejemplo n.º 2
0
        static void LucyTask(CancellationToken token)
        {
            RobotLucy lucy = new RobotLucy(locking, fillinghopper, flavorhopper, toppinghopper, hopperevent, lucyevent, convbelt);

            while (!token.IsCancellationRequested)
            {
                lucy.DoWork();
            }
        }