引用using System.Timers;
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
static
void
Main(
string
[] args)
{
Method();
#region 定时器事件
Timer aTimer = new Timer();
aTimer.Elapsed += new ElapsedEventHandler(TimedEvent);
aTimer.Interval = seconds * 1000 ; // 配置文件中配置的秒数
aTimer.Enabled = true ;
#endregion
string strLine;
do
{
strLine = Console.ReadLine();
} while (strLine != null && strLine != " exit " );
}
private static void TimedEvent( object source, ElapsedEventArgs e)
{
Method();
}
{
Method();
#region 定时器事件
Timer aTimer = new Timer();
aTimer.Elapsed += new ElapsedEventHandler(TimedEvent);
aTimer.Interval = seconds * 1000 ; // 配置文件中配置的秒数
aTimer.Enabled = true ;
#endregion
string strLine;
do
{
strLine = Console.ReadLine();
} while (strLine != null && strLine != " exit " );
}
private static void TimedEvent( object source, ElapsedEventArgs e)
{
Method();
}