public ThreadTimers(int NumberOfThreads, string fileName)
 {
     _threads             = new Dictionary <string, Timer>();
     this.NumberOfThreads = NumberOfThreads;
     this.fileName        = fileName;
     accessdatabase       = new AccessDatabase(fileName);
 }
Exemplo n.º 2
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            if (!int.TryParse(ThreadNumberInput.Text, out int NumberOfThreads))
            {
                MessageBox.Show("Incorrect input");
                return;
            }
            if (NumberOfThreads > MaxThreadCount || NumberOfThreads < MinThreadCount)
            {
                MessageBox.Show("Incorrect number of threads");
            }

            else
            {
                if (ThreadGenerationIsOn)
                {
                    threadtimers.KillAllThreadTimers();
                    threadtimers               = null;
                    accessdatabase             = null;
                    StartStopButton.Text       = "Start";
                    ThreadGenerationIsOn       = false;
                    ThreadNumberInput.ReadOnly = false;
                }

                else
                {
                    accessdatabase = new AccessDatabase();
                    if (!accessdatabase.CreateNewAccessDatabase(fileName))
                    {
                        MessageBox.Show("mdb file could not be created");
                    }
                    threadtimers         = new ThreadTimers(NumberOfThreads, fileName);
                    StartStopButton.Text = "Stop";
                    ThreadGenerationIsOn = true;
                    threadtimers.LaunchThreads(historyListView);

                    ThreadNumberInput.ReadOnly = true;
                }
            }
        }