Use below code in codebehind or in global.ashx for send mail or do any other logic on time bases.
System.Timers.Timer myTimer = new System.Timers.Timer();
myTimer.Interval = TimeSpan.FromHours(1).TotalMilliseconds;
myTimer.AutoReset = true;
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(MailTimer);
myTimer.Enabled = true;
public void MailTimer(object source, System.Timers.ElapsedEventArgs e)
{
//Use logic
}
System.Timers.Timer UnTimer = new System.Timers.Timer();
UnTimer.Interval = TimeSpan.FromMinutes(15).TotalMilliseconds;
UnTimer.AutoReset = false;
UnTimer.Elapsed += delegate { MailTimer1(s1, s2); };
UnTimer.Enabled = true;
public void MailTimer1(string s1, string s2)
{
//logic
}
myTimer.Interval = TimeSpan.FromHours(1).TotalMilliseconds;
myTimer.AutoReset = true;
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(MailTimer);
myTimer.Enabled = true;
public void MailTimer(object source, System.Timers.ElapsedEventArgs e)
{
//Use logic
}
System.Timers.Timer UnTimer = new System.Timers.Timer();
UnTimer.Interval = TimeSpan.FromMinutes(15).TotalMilliseconds;
UnTimer.AutoReset = false;
UnTimer.Elapsed += delegate { MailTimer1(s1, s2); };
UnTimer.Enabled = true;
public void MailTimer1(string s1, string s2)
{
//logic
}
No comments:
Post a Comment