Timer Problem with Service

K

Kevin Antel

We have written a service that uses a timer control to check for a process
every 60 seconds. This is installed on a Windows 2003 Server w/SP1.

The problem we are running into is that the service doesn't stop, but it
seems the timer process stops. Has anyone else run into this? What have
been solutions?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Kevin Antel said:
We have written a service that uses a timer control to check for a process
every 60 seconds. This is installed on a Windows 2003 Server w/SP1.

The problem we are running into is that the service doesn't stop, but it
seems the timer process stops. Has anyone else run into this? What have
been solutions?

What Timer class r u using? You should be using System.Timers.Timer and
make sure that the AutoReset is set to true
 
K

Kevin Antel

We are using System.Timers.Timer and we do have AutoReset set to True.
m_Timer.AutoReset = true;
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,



Kevin Antel said:
We are using System.Timers.Timer and we do have AutoReset set to True.
m_Timer.AutoReset = true;

What the service does?
Does it happen the first time or after several events?
Are you handling all the exceptions ? using AppDomain.UnHandledException

I have a similar environment and I haven't had any problem yet, the timer
(and a filesystemwatcher) works as expected all the time.
 
K

Kevin Antel

I have read that this doesn't happen to everyone. I have also heard that it
works under Windows 2000, but not always under 2003.

The service is simple. It waits 60 seconds, then logs into a mailbox to
push files into a SQL DB.

We can't physically recreate the problem. Instead, we encounter the problem
after about 20 - 30 days of running. We are working on a service that will
notify us if it is in a stopped state, so we can better narrow down the
times that it runs.

We ae running on Windows 2003 w/SP1. I'll look into the Exception.
 
K

Kevin Antel

We don't believe we are getting any type of exception, it seems to be more
of a disconnect between the timer and the worker thread.
 
W

Willy Denoyette [MVP]

Do you happen to call Stop on the server instance in your Elapsed event
handler?

Willy.

|I have read that this doesn't happen to everyone. I have also heard that
it
| works under Windows 2000, but not always under 2003.
|
| The service is simple. It waits 60 seconds, then logs into a mailbox to
| push files into a SQL DB.
|
| We can't physically recreate the problem. Instead, we encounter the
problem
| after about 20 - 30 days of running. We are working on a service that
will
| notify us if it is in a stopped state, so we can better narrow down the
| times that it runs.
|
| We ae running on Windows 2003 w/SP1. I'll look into the Exception.
|
| "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote
| in message | > Hi,
| >
| >
| >
| > | >> We are using System.Timers.Timer and we do have AutoReset set to True.
| >> m_Timer.AutoReset = true;
| >>
| >
| > What the service does?
| > Does it happen the first time or after several events?
| > Are you handling all the exceptions ? using AppDomain.UnHandledException
| >
| > I have a similar environment and I haven't had any problem yet, the
timer
| > (and a filesystemwatcher) works as expected all the time.
| >
| >
| >
| >
| > --
| > Ignacio Machin,
| > ignacio.machin AT dot.state.fl.us
| > Florida Department Of Transportation
| >
| >
| >
|
|
 
M

mwolf

why dont you instead of using a timer, simply put the current thread
asleep for a minute? I have many services that do similar things, and
I just have them in an infinite loop w/ a sleep. Then on service stop,
I kill the threads.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Kevin Antel said:
We don't believe we are getting any type of exception, it seems to be more
of a disconnect between the timer and the worker thread.


I have a service that use a timer running in both 2003 and 2K , I have no
get an error until now.

Have you seen another posts like yours?

I would check for the exception, what you do in the handler? maybe is there
where it's failing
 
A

Adam Benson

Hi,

It may be of use to you to know that we have experienced serious problems
with System.Timers.Timer.
It would run for a while, and then for no reason we could fathom it would
stop.
To observe this we had to run a dozen or so instances of our app over the
weekend and usually just one of them would fail.

When we switched to a dedicated thread the problem was fixed.

My recommendation : don't use System.Timers.Timer

Hope this helps,

Cheers,

Adam.
 
W

Willy Denoyette [MVP]

Sorry should read: .... call Stop on the 'timer' instance in your Elapsed
event
handler?


Willy.

| Do you happen to call Stop on the server instance in your Elapsed event
| handler?
|
| Willy.
|
| ||I have read that this doesn't happen to everyone. I have also heard that
| it
|| works under Windows 2000, but not always under 2003.
||
|| The service is simple. It waits 60 seconds, then logs into a mailbox to
|| push files into a SQL DB.
||
|| We can't physically recreate the problem. Instead, we encounter the
| problem
|| after about 20 - 30 days of running. We are working on a service that
| will
|| notify us if it is in a stopped state, so we can better narrow down the
|| times that it runs.
||
|| We ae running on Windows 2003 w/SP1. I'll look into the Exception.
||
|| "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
| wrote
|| in message || > Hi,
|| >
|| >
|| >
|| > || >> We are using System.Timers.Timer and we do have AutoReset set to True.
|| >> m_Timer.AutoReset = true;
|| >>
|| >
|| > What the service does?
|| > Does it happen the first time or after several events?
|| > Are you handling all the exceptions ? using
AppDomain.UnHandledException
|| >
|| > I have a similar environment and I haven't had any problem yet, the
| timer
|| > (and a filesystemwatcher) works as expected all the time.
|| >
|| >
|| >
|| >
|| > --
|| > Ignacio Machin,
|| > ignacio.machin AT dot.state.fl.us
|| > Florida Department Of Transportation
|| >
|| >
|| >
||
||
|
|
 
G

Guest

Hi Kevin,
Have you found a solution to this problem? I have same problem except that
my service is written in vb.net.
 

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