If you wand to run a threaded process at a defined period of time the System.Threading.Timer
class will be perfect
var timer = new System.Threading.Timer((o) =>
{
// do stuff every minute(60000ms)
}, null, 0, 60000);
However if you are updating any UI code from this thread dont forget to invoke back on the UI thread
WPF:
var timer = new System.Threading.Timer((o) =>
{
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
// do stuff WPF UI safe
});
}, null, 0, 60000);
Winform
var timer = new System.Threading.Timer((o) =>
{
base.Invoke((Action)delegate
{
// do stuff Winforms UI safe
});
}, null, 0, 60000);
Example:
private void StartUpdateTimer()
{
var timer = new System.Threading.Timer((o) =>
{
string ss = "gowtham " + DateTime.Now.ToString();
Response.Write(ss);
}, null, 0,1000);
}