예제 #1
0
        static void Main()
        {
            Console.WriteLine("Application started !");
            var factory = new CakeFactory(TimeSpan.FromMinutes(1));

            factory.OnReceiveStatusNotification = (createdCookies) => Console.WriteLine(createdCookies);

            var preparing = new StepBalancer(3, "On Preparing", new StepDefinition {
                MinimalTimeProcessing = 5, MaximalTimeProcessing = 8
            });
            var cook = new StepBalancer(5, "On cook", new StepDefinition {
                MinimalTimeProcessing = 10, MaximalTimeProcessing = 10
            });
            var package = new StepBalancer(2, "On package", new StepDefinition {
                MinimalTimeProcessing = 2, MaximalTimeProcessing = 2
            });

            factory.AddStepBalancing(preparing);
            factory.AddStepBalancing(cook);
            factory.AddStepBalancing(package);

            factory.Run();
            Console.WriteLine("Factory started !");
            Console.Read();
            Console.WriteLine("Stopping factory");
            factory.Stop();
            factory.Dispose();
        }
예제 #2
0
        public void AddStepBalancing(StepBalancer balancer)
        {
            if (balancer == null)
            {
                throw new ArgumentNullException(nameof(balancer));
            }

            if (_balancers.Any())
            {
                _balancers.Last().OnElementComplete = balancer.Produce;
            }
            _balancers.Add(balancer);
        }