Hi Folks
I've got a class called Timer with the following code:
public class Timer
{
public static void Main(String[] args)
{
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimer);
aTimer.Interval = 10000;
aTimer.Enabled = true;
Console.WriteLine("Press \'q\' to quit the timer"
while(Console.Read()!='q');
}
public static void OnTimer(Object source, ElapsedEventArgs e)
{
CopyFiles MyCopyFiles = new CopyFiles(); // Create instance
MyCopyFiles.CheckDir();
}
}
As you can see, every 10 seconds the timer calls the CheckDir method in the CopyFiles class. My question is this: does the Timer class call this method and then WAIT until the method has finished running before carrying on OR does the Timer simply call the method after EVERY 10 seconds? I'm a bit confused!
If the latter is the case, I'd like to be able to pause the timer while the CheckDir method is running. Any ideas on how I can do this?
Thanks for any help,
Kenny.
I've got a class called Timer with the following code:
public class Timer
{
public static void Main(String[] args)
{
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimer);
aTimer.Interval = 10000;
aTimer.Enabled = true;
Console.WriteLine("Press \'q\' to quit the timer"
while(Console.Read()!='q');
}
public static void OnTimer(Object source, ElapsedEventArgs e)
{
CopyFiles MyCopyFiles = new CopyFiles(); // Create instance
MyCopyFiles.CheckDir();
}
}
As you can see, every 10 seconds the timer calls the CheckDir method in the CopyFiles class. My question is this: does the Timer class call this method and then WAIT until the method has finished running before carrying on OR does the Timer simply call the method after EVERY 10 seconds? I'm a bit confused!
If the latter is the case, I'd like to be able to pause the timer while the CheckDir method is running. Any ideas on how I can do this?
Thanks for any help,
Kenny.