private void timer1_Tick(object sender, EventArgs e)
        {
            if (cmdScan.Text == "Stop Dump")
            {
                string current_time = DateTime.Now.ToString("HHmmss");



                if (restart_times.IndexOf(current_time) != -1)
                {
                    Logger.Instance.Write("Stop dump requested");
                    workerDump.CancelAsync();
                    resetEvent.WaitOne(new TimeSpan(0, 0, 45));


                    Thread.Sleep(1000);

                    if (last_dump_parameters != null)
                    {
                        string val = ScriptRunner.run_after_finish(last_dump_parameters.FileName, get_active_tuner_idx(), after_recording_complete_script_path.Text);
                    }

                    start_dump();
                }
            }


            try
            {
                string[] to_add = (string[])Logger.last_log.ToArray(typeof(string));



                for (int i = 0; i < to_add.Length; i++)
                {
                    string str_to_add = to_add[i];
                    if (str_to_add != null)
                    {
                        last_log.Items.Add(str_to_add);
                    }
                }
            }
            catch (Exception er) { }


            last_log.SelectedIndex = last_log.Items.Count - 1;

            Logger.last_log.Clear();
        }
        private void cmdScan_Click(object sender, EventArgs e)
        {
            if (cmdScan.Text == "Stop Dump")
            {
                Logger.Instance.Write("Stop dump requested");
                workerDump.CancelAsync();
                resetEvent.WaitOne(new TimeSpan(0, 0, 45));
                cmdScan.Text         = "Start Dump";
                lblScanning.Visible  = false;
                pbarProgress.Visible = false;
                pbarProgress.Enabled = false;


                if (last_dump_parameters != null)
                {
                    string val = ScriptRunner.run_after_finish(last_dump_parameters.FileName, get_active_tuner_idx(), after_recording_complete_script_path.Text);
                }


                ChangeControlStatus(true);


                return;
            }

            if (!checkData())
            {
                return;
            }



            DateTime st_time = DateTime.ParseExact(start_hour_textbox.Text, "HH:mm", CultureInfo.InvariantCulture);
            int      hour    = st_time.Hour;
            int      minute  = st_time.Minute;
            int      second  = 0;

            int current_second = -1;
            int current_minute = -1;
            int current_hour   = -1;

            DumpParameters dp = getDumpParameters();

            restart_times.Clear();

            while (!(current_hour == hour && current_minute == minute && current_second == second))
            {
                st_time        = st_time.AddSeconds(dp.DataCollectionTimeout);
                current_hour   = st_time.Hour;
                current_minute = st_time.Minute;
                current_second = st_time.Second;

                restart_times.Add(st_time.ToString("HHmmss"));
                // Logger.Instance.Write(string.Format("restart time: {0}",calc_time.ToString()));
            }

            Logger.Instance.Write("Dump started");

            cmdScan.Text = "Stop Dump";

            start_dump();
        }