C
Curious
Hi,
I have a timer object that's launched as below:
mTimer = new System.Threading.Timer (new
TimerCallBack(SubscribeTrade), null, 15000, 15000);
void SubscribeTrade (object state)
{
DateTime now = DateTime.Now;
TimeSpan elapsed = now.Subtract(mStartTime);
int minutes = elapsed.Minutes;
if (minutes <= 30)
{
//Code omitted here
}
else // Need to destroy the timer after 30 minutes here
{
// Is this the right way to destroy the timer object?
mTimer.Dispose();
}
}
As shown in my code, I need to destroy the timer after it's run for 30
minutes. Will it cause a problem if I dispose the timer inside its
callback method, "SubscribeTrade"?
If it will, how can I destroy it in 30 minutes?
I have a timer object that's launched as below:
mTimer = new System.Threading.Timer (new
TimerCallBack(SubscribeTrade), null, 15000, 15000);
void SubscribeTrade (object state)
{
DateTime now = DateTime.Now;
TimeSpan elapsed = now.Subtract(mStartTime);
int minutes = elapsed.Minutes;
if (minutes <= 30)
{
//Code omitted here
}
else // Need to destroy the timer after 30 minutes here
{
// Is this the right way to destroy the timer object?
mTimer.Dispose();
}
}
As shown in my code, I need to destroy the timer after it's run for 30
minutes. Will it cause a problem if I dispose the timer inside its
callback method, "SubscribeTrade"?
If it will, how can I destroy it in 30 minutes?