J
jam
Dear all,
I am wrtiing a console application and doing some test on timer, the below
is my sample code I got from some site, but I cannot make it work...
Error is
'System.Timers.Timer' does not contain a definition for 'Tick'
So what should i do???
the final thing I wanna get is, I have a console will call a exe running in
background, and then I wanna check it is is still running ( Use get process
by name here to check if it is still running), then if running, check it
after 1 min.
Thx for helping.
Codes:
int numbertext =0;
void TickHandler( object sender, EventArgs e )
{
Console.WriteLine(numbertext);
numbertext ++;
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// usage block
{
// create timer
Timer kicker = new Timer() ;
kicker.Interval = 1000 ;
kicker.AutoReset = false ;
// add handler
kicker.Tick += new EventHandler( TickHandler ) ;
// start timer
kicker.Start() ;
// change interval
kicker.Interval = 2000 ;
// stop timer
kicker.Stop() ;
// you can start and stop timer againg
kicker.Start() ;
kicker.Stop() ;
}
}
I am wrtiing a console application and doing some test on timer, the below
is my sample code I got from some site, but I cannot make it work...
Error is
'System.Timers.Timer' does not contain a definition for 'Tick'
So what should i do???
the final thing I wanna get is, I have a console will call a exe running in
background, and then I wanna check it is is still running ( Use get process
by name here to check if it is still running), then if running, check it
after 1 min.
Thx for helping.
Codes:
int numbertext =0;
void TickHandler( object sender, EventArgs e )
{
Console.WriteLine(numbertext);
numbertext ++;
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// usage block
{
// create timer
Timer kicker = new Timer() ;
kicker.Interval = 1000 ;
kicker.AutoReset = false ;
// add handler
kicker.Tick += new EventHandler( TickHandler ) ;
// start timer
kicker.Start() ;
// change interval
kicker.Interval = 2000 ;
// stop timer
kicker.Stop() ;
// you can start and stop timer againg
kicker.Start() ;
kicker.Stop() ;
}
}