Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Timers!!!
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00943610
Message ID:
00943690
Views:
18
I am not sure I understand what you want the timer to do. A timer object is an object that will perform a task every time it's elapsed event fires.
Here is some sample code that should get you started:
// Initialize and start the timer
oServiceTimer = new System.Timers.Timer(); // create your timer object
oServiceTimer.Elapsed += new System.Timers.ElapsedEventHandler(oServiceTimer_Elapsed); // add the method to run when the elapsed event fires
oServiceTimer.Interval = 1000 * 15; // 15 sec intervals
oServiceTimer.AutoReset = true; // if this is false the timer will only fire once
oServiceTimer.Start(); // Start the timer
oServiceTimer_Elapsed(this,null); // Call the oServiceTimer_Elapsed event manually so we don't have to wait for the interval

private void oServiceTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
  MessageBox.Show("I fired");
}
Hope this helps you get started.

Einar

>I have added a timer to one of my forms.
>I want the timer to count down in seconds
>
>I have the following code in my form :
>
>Where is the time elapsed?
>And is this the right code to get the timer to start?
>Interval is 15,000 to equal 15 seconds.
>
>
>
>this.tmrSQLConnection.Enabled = true;			
>this.tmrSQLConnection.Start();
>	lResult = MyTestValues.TestServer(this.txtSQLUserID.Text.Trim(),this.txtSQLPassword.Text.Trim(),this.txtServerName.Text.Trim());
>this.tmrSQLConnection.Stop();
>this.tmrSQLConnection.Enabled = false;
>
>
>		private void tmrSQLConnection_Tick(object sender, System.EventArgs e)
>		{
>			int TimeValue = 0;
>			TimeValue = (this.tmrSQLConnection.Interval/1000);
>			this.lblStatus.Text = "Time Remaining (" + TimeValue.ToString() + ")";
>			this.lblStatus.Update();
>		}
>
>
Semper ubi sub ubi.
Previous
Reply
Map
View

Click here to load this message in the networking platform