To use a timer:
using System.Timers;
...
// NB put this next declaration at class level,
// not in a method where 'tick' will be
// garbage collected before it can fire
System.Timers.Timer tick;
...
tick = new System.Timers.Timer(10000);
// include the next line if you want event handler to interact with controls
// (eg setting text)
tick.SynchronizingObject = this;
tick.Elapsed += new ElapsedEventHandler(this.tickElapsed);
tick.Enabled = true;
...
void tickElapsed(object source, ElapsedEventArgs e)
{
...
}
If your timer is failing to eg set text on a control, check that you included the SynchronizingObject set.
Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.
Quick
- ($a, $b....) = unpack("A2A7...", $packed)
- push( array, list )
Followers
Blog Archive
-
▼
2010
(89)
-
▼
April
(18)
- .NET timers
- DataRow Field
- Insert into DataRowCollection
- .NET collections
- C# constructors
- C# properties
- .NET treeview
- C# foreach
- .NET treenode key
- rank()
- C# shell command
- C# window interaction
- VNC
- C# index out of bounds
- C# command line arguments
- C# string indexes
- C# implicit conversion
- C# and static-ness
-
▼
April
(18)