Reply to thread

I have this click button event where i start the timer3:

 

<pre class="prettyprint private void button5_Click(object sender, EventArgs e)

        {

            _indx = 0;

            if (HistogramLoadedFile == true)

            {

                DirectoryInfo dir = new DirectoryInfo(directoryName);

                if (_files == null)

                    _files = new List<FileInfo>();


                FileInfo[] fi = dir.GetFiles("*.bmp");

                _files.AddRange(fi);


                _files = _files.OrderBy(f => f.LastWriteTime).ToList();

                button5.ForeColor = Color.Red;

                button6.ForeColor = Color.Black;

                button7.ForeColor = Color.Black;

                timer3.Start();

                button6.Enabled = true;

                button6.Text = "Pause";

                button7.Enabled = true;

            }

            else

            {

                DirectoryInfo dir = new DirectoryInfo(subDirectoryName);

                if (_files == null)

                    _files = new List<FileInfo>();


                FileInfo[] fi = dir.GetFiles("*.bmp");

                if (fi.Length == 0)

                {

                    fi = _fi;

                }

                _files.AddRange(fi);


                _files = _files.OrderBy(f => f.LastWriteTime).ToList();

                button5.ForeColor = Color.Red;

                button6.ForeColor = Color.Black;

                button7.ForeColor = Color.Black;

                timer3.Start();

                button6.Enabled = true;

                button6.Text = "Pause";

                button7.Enabled = true;

            }

        }[/code]

 And then the timer3 tick event:

 

<pre class="prettyprint private void timer3_Tick(object sender, EventArgs e)

        {

            //timer3.Stop();

                try

                {

                    Image iOLd = this.pictureBox1.Image;

                    Image img = Image.FromFile(_files[_indx].FullName);

                    myTrackPanelss1.trackBar1.Value = _indx;

                    label22.Text = _files[_indx].Name;

                    this.pictureBox1.Image = img;


                    if (iOLd != null)

                        iOLd.Dispose();


                    _indx++;


                    if (_indx >= _files.Count)

                        _indx = 0;


                    timer3.Interval = 10;

                    timer3.Start();

                }

                catch

                {


                }


           

        }[/code]

 The timer interval is set to 10. So why its moving so slow ? And why in the end the timer stop ?

 The end i mean when the trackBar1 slider get to the end. Instead of repeating and keep playing it stop i dont understand why.

 Two strange things. And this is the only place i set in my code the timer3 interval.

 1. Why its slow ?

 2. Why it stop in the end ?

 And the variable _files contain 2255 files(indexs)  inside. <hr class="sig  danieli


View the full article


Back
Top