Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Workers <Product> workers = new Workers <Product>(
                new List <IWorkHandler <Product> >()
            {
                new WorkHandler(), new WorkHandler()
            });

            Producer <Product> producerWorkers  = workers.CreateOneProducer();
            Producer <Product> producerWorkers1 = workers.CreateOneProducer();

            workers.Start();
            Task.Run(delegate
            {
                while (true)
                {
                    Thread.Sleep(1000);
                    Seconds++;
                    long intemp = PkgInCount;
                    long outemp = PkgOutCount;
                    Console.WriteLine(
                        $"In ops={intemp - PrePkgInCount},out ops={outemp - PrePkgOutCount},inCacheCount={InCache.Count},OutCacheCount={OutCache.Count},RunningTime={Seconds}");
                    PrePkgInCount  = intemp;
                    PrePkgOutCount = outemp;
                }
            });
            Task.Run(delegate { Run(producerWorkers); });
            Task.Run(delegate { Run(producerWorkers); });
            Task.Run(delegate { Run(producerWorkers1); });
            Console.Read();
        }