protected void Page_Load(object sender, EventArgs e)
{
System.Timers.Timer aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
aTimer.AutoReset = false;
aTimer.Enabled = true;
System.Threading.Thread.Sleep(1500);
}
private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
{
Response.Write("定时器已触发!");
}
{
System.Timers.Timer aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
aTimer.AutoReset = false;
aTimer.Enabled = true;
System.Threading.Thread.Sleep(1500);
}
private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
{
Response.Write("定时器已触发!");
}