01usingSystem;01usingSystem;
02usingSystem.Timers;
03
04classTestTimer
05{
06publicstaticvoidMain ()
07{
08Timer timer = newTimer();
09timer.Elapsed + = newElapsedEventHandler(DisplayTimeEvent);
10timer.Interval = 1000;
11timer.Start();
12timer.Enabled = true;
13
14while(Console.Read ()! = 'q')
15{
16//-------------
17}
18}
19
20publicstaticvoidDisplayTimeEvent (objectsource, ElapsedEventArgs e)
21{
22Console.Write({0}, DateTime.Now);
23}
24}
.code_report{float:right} .code_report div{ float: left; margin-left: 5px; background: url("/img/ask-icon.gif") no-repeat; padding: 6px 0 6px 15px; padding-left: 15px; height: 16px;} .code_report a{ background: url("/img/ask-icon.gif") 0 -160px no-repeat;padding-left: 20px; line-height: 15px;height: 16px; color: #333; text-decoration: none; display:inline-block; zoom:1; vertical-align: middle;} .code_report em{ height: 28px; line-height:28px; width: 14px; display: inline-block; float: left; background: url("/img/ask-icon.gif") top right;}
01usingSystem;
02usingSystem.Timers;
03
04classTestTimer
05{
06publicstaticvoidMain ()
07{
08Timer timer = newTimer();
09timer.Elapsed + = newElapsedEventHandler(DisplayTimeEvent);
10timer.Interval = 1000;
11timer.Start();
12timer.Enabled = true;
13
14while(Console.Read ()! = 'q')
15{
16//-------------
17}
18}
19
20publicstaticvoidDisplayTimeEvent (objectsource, ElapsedEventArgs e)
21{
22Console.Write({0}, DateTime.Now);
23}
24}