System.Timers.Timer Question

Y

Yener

I have strange situation on a Framework 2.0 windows service.
Here is elapsed event of the timer. There is breakpoint1 on Start_Process().
if i work too long debugging Start_process function or forget and go for a
tea. Debugger hits the breakpoint2 inside the finally block. How come could
this happen?

private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{

timer1.Enabled = false;
Start_Process() // BreakPoint 1
}
catch (System.Exception Ex)
{

//Do exception handling
}
finally
{
timer1.Interval = GetTimerInterval(); // BreakPoint 2
timer1.Enabled = true;
}
}


thnks
 
I

Israel

Are you sure that there aren't actually two threads comming in and
then when you step into Start_Process() on one thread the other thread
is just running through that and ending up at the finally block.
That's my only thought since the timer events come in on arbitrary
thread pool threads and, unlike the UI timer, will just keep coming
until you eat up your thread pool.
 
Y

Yener

I am running whole solution in my local machine. Under normal
circumstances,it is not possible that another thread would run while timer
is disabled. There is a windows service that make use of web services and
more than 60 other projects on business and db layers. It was also hard to
prepare the system for debugging. Sometimes , strange things are happening, i
dunno why.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top