예제 #1
0
        private void OnWorkDone(object sender, EventArgs e)
        {
            //this.buttonStart.Enabled = true;
            this.Invoke((MethodInvoker) delegate { buttonStart.Enabled = true; });
            this.Invoke((MethodInvoker) delegate { buttonGeneratorUpdate.Enabled = true; });
            this.Invoke((MethodInvoker) delegate { this.buttonUpdateProcessor1.Enabled = true; });
            this.Invoke((MethodInvoker) delegate { this.buttonUpdateProcessor2.Enabled = true; });
            this.Invoke((MethodInvoker) delegate { this.buttonUpdateProcessor3.Enabled = true; });
            this.Invoke((MethodInvoker) delegate { this.buttonUpdateProcessor4.Enabled = true; });
            this.Invoke((MethodInvoker) delegate { this.buttonUpdateProcessor5.Enabled = true; });
            ResetProgressBarsValues();

            this.Invoke((MethodInvoker) delegate { timeCalculator.SetSecondTime(); });

            this.Invoke((MethodInvoker) delegate // show results
            {
                labelTotalTime.Text       = "Total time: " + timeCalculator.TimeOfWork().ToString();
                labelProcessedTasks.Text  = "Processed tasks: " + totalProcesses.ToString();
                labelTotalOperations.Text = "Total operations: " + totalOperations.ToString();
            });


            //this.manager.processors.All(p => { p.NewProcessStarted += OnNewProcessStarted; return true; }); // reload subscribes (because processors reloaded)
            //this.manager.processors.All(p => { p.ProgressChanged += OnProgressChanged; return true; });
            //this.manager.processors.All(p => { p.ProcessEnded += OnProcessEnded; return true; });
            int pow1      = manager.processors[0].power;
            int pow2      = manager.processors[1].power;
            int pow3      = manager.processors[2].power;
            int pow4      = manager.processors[3].power;
            int pow5      = manager.processors[4].power;
            int sleepTime = manager.generator.sleepTime;
            int scope1    = manager.generator.taskComplexityScope[0];
            int scope2    = manager.generator.taskComplexityScope[1];
            int worktime  = manager.generator.workingTime;

            //string met = manager.method;
            //manager = new Manager(manager.processors[0].power, manager.processors[1].power, manager.processors[2].power, manager.processors[3].power, manager.processors[4].power,
            //    manager.generator.indexSleepBetweenTask, manager.generator.taskComplexityScope[0], manager.generator.taskComplexityScope[1], manager.generator.workingTime, manager.method);
            // manager = new Manager(pow1, pow2, pow3, pow4, pow5, sleepInd, scope1, scope2, worktime, method);
            manager = new Manager();
            manager.processors[0].power = pow1;
            manager.processors[1].power = pow2;
            manager.processors[2].power = pow3;
            manager.processors[3].power = pow4;
            manager.processors[4].power = pow5;
            manager.generator.sleepTime = sleepTime;
            manager.generator.taskComplexityScope[0] = scope1;
            manager.generator.taskComplexityScope[1] = scope2;
            manager.generator.workingTime            = worktime;
            manager.method = method;

            timeCalculator = new TimeCalculator();
            // method = "";
            ManageInterface();
            ProcessorsInterface();
            totalProcesses  = 0;
            totalOperations = 0;
        }
예제 #2
0
 public Main()
 {
     InitializeComponent();
     manager        = new Manager();
     timeCalculator = new TimeCalculator();
     method         = "";
     ManageInterface();
     ProcessorsInterface();
     totalProcesses  = 0;
     totalOperations = 0;
 }