Esempio n. 1
0
 //кнопка запуска сортировки
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Random random = new Random();
         int    count  = (int)countElements.Value;
         int    min    = (int)minLim.Value;
         int    max    = (int)(maxLim.Value + 1);
         FillArray.generate_rand_data_for_array(ref array, count, min, max);
         if (MyThread1 != null)
         {
             if (!MyThread1.IsAlive) //проверка на выполнение потока. Не запускать, если он запущен
             {
                 //главный запуск
                 start(ref pictureBox1, ref comboBox1, array, ref MyThread1, min, max);
             }
         }
         else
         {
             //главный запуск
             start(ref pictureBox1, ref comboBox1, array, ref MyThread1, min, max);
         }
     }
     catch
     {
         MessageBox.Show("Error", "Неизвестная ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
 //Расчет времени сортировки
 //Вывод в label
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         PictureBox p1 = null;
         time_sort.Text = null;
         int minim = (int)min.Value;
         int maxim = (int)max.Value;
         if (!radioButton2.Checked)
         {
             array = new int[(int)count.Value];
             FillArray.generate_rand_data_for_array(ref array, (int)count.Value, minim, maxim);
         }
         Stopwatch timer = new Stopwatch();
         timer.Start();
         Main.start(ref p1, ref comboBox1, array, ref MyThread1, minim, maxim);
         MyThread1.Join();
         timer.Stop();
         time_sort.Text = timer.ElapsedMilliseconds + " ms";
     }
     catch
     {
         MessageBox.Show("Ошибка. Недостаточно памяти или неверный диапазон");
     }
 }