Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
text file has following line
9.3213719
which is position of video at particular time in seconds
i want to show this value in textbox when video reaches at that time(stored in txt file)
i have successfully shown the value in textbox .....but there is a problem
according to txt file textbox should display value of 9 when video reaches at 9th second
but textbox displaying 6 instead of 9 at video position of 6 instead of 9th second
doing this in tick event of timer
code is below
C#
private void timer1_Tick(object sender, EventArgs e)
        {
            string line = "aa";
            string file="e:\\"+list_nomber.Text+".txt";
            System.IO.StreamReader objreader;
            objreader=new System.IO.StreamReader(file);
            while((line=objreader.ReadLine())!= null)
            {
                x =Convert.ToDouble(line);
                end = Convert.ToInt32(x);
                if (Convert.ToInt32(MyVideo.CurrentPosition) == end)
                {
                    textBox1.Text = end.ToString();
                    timer1.Stop();
                
            }
            }
            objreader.Close();
}
Posted
Comments
Can you debug and see respective values inside this event while video position is 9?
BillWoodruff 11-Dec-13 1:52am    
While there may be other "synchronization" issues here, the thing that "jumps-out" at me, looking at your code, is that you are reading the file every time there's a Timer 'Tick Event. That's got to be inefficient.

I would first look for a way, if possible, to read the File, and store significant values in advance of starting the Timer, so that the Timer can just look-up a value, as needed, in some generic List or other data-structure.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900