Esempio n. 1
0
        private void runReasearch_Click(object sender, EventArgs e)
        {
            ResearchWindow rw = new ResearchWindow();

            rw.FormClosing += (obj, param) =>
            {
                var window = (ResearchWindow)obj;
                ResearchNBN.NeuronNumber      = window.MaxNeurons;
                ResearchNBN.RepeatForEachFile = window.MaxTrials;
                ResearchNBN.PDF = window.GeneratePDF;
                bool flag = window.CanRun;

                if (flag)
                {
                    if (window.Items.Count == 0)
                    {
                        info = Resource.Inst.Get("r186");
                        return;
                    }
                    worker = new BackgroundWorker();
                    worker.WorkerReportsProgress      = true;
                    worker.WorkerSupportsCancellation = true;

                    worker.ProgressChanged += (a, b) =>
                    {
                        info = b.ProgressPercentage.ToString() + " z " + ((int)status.Tag).ToString();
                    };

                    worker.DoWork += (a, b) =>
                    {
                        ResearchNBN test = new ResearchNBN();
                        test.Items     = (List <string>)b.Argument;
                        test.OnUpdate += (counter) =>
                        {
                            ((BackgroundWorker)a).ReportProgress(counter);
                        };
                        test.Run();
                    };

                    worker.RunWorkerCompleted += (a, b) =>
                    {
                        showHistory();
                        stopReasearch.Visible = false;
                        info = "";
                    };

                    int count = window.Items.Count * ResearchNBN.NeuronNumber * ResearchNBN.RepeatForEachFile;
                    status.Tag = count;
                    info       = String.Format(Resource.Inst.Get("r187"), count.ToString());
                    worker.RunWorkerAsync(window.Items);
                }
            };
            rw.ShowDialog();
        }
Esempio n. 2
0
        private void runReasearch_Click(object sender, EventArgs e)
        {
            ResearchWindow rw = new ResearchWindow();
            rw.FormClosing += (obj, param) =>
            {
                var window = (ResearchWindow)obj;
                ResearchNBN.NeuronNumber = window.MaxNeurons;
                ResearchNBN.RepeatForEachFile = window.MaxTrials;
                ResearchNBN.PDF = window.GeneratePDF;
                bool flag = window.CanRun;

                if (flag)
                {
                    if (window.Items.Count == 0)
                    {
                        info = Resource.Inst.Get("r186");
                        return;
                    }
                    worker = new BackgroundWorker();
                    worker.WorkerReportsProgress = true;
                    worker.WorkerSupportsCancellation = true;

                    worker.ProgressChanged += (a, b) =>
                    {
                        info = b.ProgressPercentage.ToString() + " z " + ((int)status.Tag).ToString();
                    };

                    worker.DoWork += (a, b) =>
                    {
                        ResearchNBN test = new ResearchNBN();
                        test.Items = (List<string>)b.Argument;
                        test.OnUpdate += (counter) =>
                        {
                            ((BackgroundWorker)a).ReportProgress(counter);
                        };
                        test.Run();
                    };

                    worker.RunWorkerCompleted += (a, b) =>
                    {
                        showHistory();
                        stopReasearch.Visible = false;
                        info = "";
                    };

                    int count = window.Items.Count * ResearchNBN.NeuronNumber * ResearchNBN.RepeatForEachFile;
                    status.Tag = count;
                    info = String.Format(Resource.Inst.Get("r187"), count.ToString());
                    worker.RunWorkerAsync(window.Items);
                }
            };
            rw.ShowDialog();
        }