Hi Folks
I'm experimenting with the Timer method and have written the following code (don't laugh until you've read my questions - I know I'm not very good at this!!!). However, I've got two problems:
...
// Passes NewName to the Namer method
MyName.Namer(NewName);
...
public void Namer(string name) // I can pass it here but I don't need it here!!
{
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnNamerTimer);
aTimer.Interval = 5000;
aTimer.Enabled = true;
Console.WriteLine("Press \'q\' to quit the exit timer"
while(Console.Read()!='q');
}
public static void OnNamerTimer(Object source, ElapsedEventArgs e)
{
System.Timers.Timer aTimer = source as System.Timers.Timer;
string name = **name in Namer**;
...
...
}
1. How can I pass the NewName variable to OnNamerTimer? I can pass it to Namer OK but I don't need to use it here! I can't seem to pass it to OnNamerTimer without getting an error.
2. I copied the timer code from an example program. How can I change the code so that I can get rid of the Console.WriteLine("Press \'q\' to quit the exit timer" stuff?
Cheers for any help!
Kenny.
I'm experimenting with the Timer method and have written the following code (don't laugh until you've read my questions - I know I'm not very good at this!!!). However, I've got two problems:
...
// Passes NewName to the Namer method
MyName.Namer(NewName);
...
public void Namer(string name) // I can pass it here but I don't need it here!!
{
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnNamerTimer);
aTimer.Interval = 5000;
aTimer.Enabled = true;
Console.WriteLine("Press \'q\' to quit the exit timer"
while(Console.Read()!='q');
}
public static void OnNamerTimer(Object source, ElapsedEventArgs e)
{
System.Timers.Timer aTimer = source as System.Timers.Timer;
string name = **name in Namer**;
...
...
}
1. How can I pass the NewName variable to OnNamerTimer? I can pass it to Namer OK but I don't need to use it here! I can't seem to pass it to OnNamerTimer without getting an error.
2. I copied the timer code from an example program. How can I change the code so that I can get rid of the Console.WriteLine("Press \'q\' to quit the exit timer" stuff?
Cheers for any help!
Kenny.