Passing Information to Timer.Elapsed Method
-
Hi guys! I have a question concerning the Timer Elapse Event and the invoked Method. Is it possible to add an object to the timer which is passed to the Method? Something like this:
public Timer MouseHooverTimer
{
get
{
if (mouseHooverTimer == null)
{
mouseHooverTimer = new Timer(2000);
mouseHooverTimer.Elapsed += new ElapsedEventHandler(mouseHooverTimer_Elapsed);
}
return mouseHooverTimer;
}
}private void StartTimer(object information)
{
mouseHooverTimer.Start(); <== HERE ADD THE OBJECT information
}void mouseHooverTimer_Elapsed(object sender, ElapsedEventArgs e)
{
//HERE USE THE OBJECT information
}Thanks in advance!
-
Hi guys! I have a question concerning the Timer Elapse Event and the invoked Method. Is it possible to add an object to the timer which is passed to the Method? Something like this:
public Timer MouseHooverTimer
{
get
{
if (mouseHooverTimer == null)
{
mouseHooverTimer = new Timer(2000);
mouseHooverTimer.Elapsed += new ElapsedEventHandler(mouseHooverTimer_Elapsed);
}
return mouseHooverTimer;
}
}private void StartTimer(object information)
{
mouseHooverTimer.Start(); <== HERE ADD THE OBJECT information
}void mouseHooverTimer_Elapsed(object sender, ElapsedEventArgs e)
{
//HERE USE THE OBJECT information
}Thanks in advance!
No, just use a field. Or derive your own timer class that will do it.
-
No, just use a field. Or derive your own timer class that will do it.
-
Hi guys! I have a question concerning the Timer Elapse Event and the invoked Method. Is it possible to add an object to the timer which is passed to the Method? Something like this:
public Timer MouseHooverTimer
{
get
{
if (mouseHooverTimer == null)
{
mouseHooverTimer = new Timer(2000);
mouseHooverTimer.Elapsed += new ElapsedEventHandler(mouseHooverTimer_Elapsed);
}
return mouseHooverTimer;
}
}private void StartTimer(object information)
{
mouseHooverTimer.Start(); <== HERE ADD THE OBJECT information
}void mouseHooverTimer_Elapsed(object sender, ElapsedEventArgs e)
{
//HERE USE THE OBJECT information
}Thanks in advance!