C#: timer interval run-time user settings???????

Q. How do you code a timer so a user can change the interval settings for a finished and running application???

I realize they would probably have to close and reopen the application for the settings to take effect..........

I tried this with complie errors:   timer1.Internal = txtBox1.Text
LVL 1
kvnsdrAsked:
Who is Participating?
 
tzxie2000Connect With a Mentor Commented:
please stop the timer and restart it like code below

timer1.stop();
timer1.Interval=Integer.Parse(txtBox1.Text);
timer1.start();
0
 
Razzie_Commented:
If you use the System.Threading.Timer object, you can use the Timer.Change() method.

This method takes, for example, a TimeSpan object, when the timer should invoke it methods, and as a second parameter, when the timer should re-invoke its method.

If you're using another timer object, let me know.
0
 
kvnsdrAuthor Commented:
I'm using a simple drag-n-drop Timer1 with VS C# .NET, no threading...........
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
kvnsdrAuthor Commented:
Integer (type or reference could not be found, error)
0
 
tzxie2000Connect With a Mentor Commented:
sorry for that
please using int replaced Integer
as in delphi int is Integer
sorry for that
0
 
kvnsdrAuthor Commented:
Thank you, the complete code is below for anyone else's use.

private void button1_Click(object sender, System.EventArgs e)
{
this.timer1.Stop();
this.timer1.Interval = int.Parse(textBox2.Text);
this.timer1.Start();
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.