Solved

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

Posted on 2004-09-10
6
1,521 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:kvnsdr
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Razzie_
ID: 12031259
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
 
LVL 1

Author Comment

by:kvnsdr
ID: 12031897
I'm using a simple drag-n-drop Timer1 with VS C# .NET, no threading...........
0
 
LVL 5

Accepted Solution

by:
tzxie2000 earned 50 total points
ID: 12033199
please stop the timer and restart it like code below

timer1.stop();
timer1.Interval=Integer.Parse(txtBox1.Text);
timer1.start();
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 1

Author Comment

by:kvnsdr
ID: 12045381
Integer (type or reference could not be found, error)
0
 
LVL 5

Assisted Solution

by:tzxie2000
tzxie2000 earned 50 total points
ID: 12045407
sorry for that
please using int replaced Integer
as in delphi int is Integer
sorry for that
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 12045546
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question