473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Windows Service & System.Timers.Timer production issue...

I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.

The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.

The issue that is arising is intermittently files are being copied BUT
the database record is not being updated as expected AND there is no
error message in our logs. As I said this is an intermittent fault
that I can't reproduce on the development server even when I chuck a
large number of files (large file size as well) at it.

I want to know has anyone had any similar experiences.

Next step is to investigate the hardware & software configuration of
the production server.
Cheers

Ollie Riches
Jun 27 '08 #1
8 3343
On Apr 23, 12:28 pm, Ollie Riches <ollie.ric...@btinternet.comwrote:
I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.

The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.

The issue that is arising is intermittently files are being copied BUT
the database record is not being updated as expected AND there is no
error message in our logs. As I said this is an intermittent fault
that I can't reproduce on the development server even when I chuck a
large number of files (large file size as well) at it.

I want to know has anyone had any similar experiences.

Next step is to investigate the hardware & software configuration of
the production server.

Cheers

Ollie Riches
1) Is it possible for you to paste the code block of the TimerElapsed
event handler? That would be helpful
2) Alternatively, run Perfmon and look at the count of CLR exceptions
for your process. This should tell you if there are unhandled
exceptions
3) Consider using FileSystemWatcher ( this is an alternative and not
really the solution to your problem)

-Sriram


Jun 27 '08 #2
Check this post/thread:

http://groups.google.com/group/micro...8c53ddf8298793
I think its best to code up a TimerCallback...
have it do the work. ... and THEN code up another call to for the timer to
fire.

You'll avoid the space time continium ordeals when your code doesn't execute
before the next time a timer (the drag and drop kind) fires again.

I think that's the best way to approach it.
I would avoid
ElapsedEventHandler

and stick with this:
http://msdn2.microsoft.com/en-us/lib...rcallback.aspx

"Ollie Riches" <ol**********@btinternet.comwrote in message
news:69**********************************@24g2000h sh.googlegroups.com...
I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.

The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.

The issue that is arising is intermittently files are being copied BUT
the database record is not being updated as expected AND there is no
error message in our logs. As I said this is an intermittent fault
that I can't reproduce on the development server even when I chuck a
large number of files (large file size as well) at it.

I want to know has anyone had any similar experiences.

Next step is to investigate the hardware & software configuration of
the production server.
Cheers

Ollie Riches

Jun 27 '08 #3
On 23 Apr, 18:25, mgsram <mgs...@gmail.comwrote:
On Apr 23, 12:28 pm, Ollie Riches <ollie.ric...@btinternet.comwrote:


I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.
The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.
The issue that is arising is intermittently files are being copied BUT
the database record is not being updated as expected AND there is no
error message in our logs. As I said this is an intermittent fault
that I can't reproduce on the development server even when I chuck a
large number of files (large file size as well) at it.
I want to know has anyone had any similar experiences.
Next step is to investigate the hardware & software configuration of
the production server.
Cheers
Ollie Riches

1) Is it possible for you to paste the code block of the TimerElapsed
event handler? That would be helpful
2) Alternatively, run Perfmon and look at the count of CLR exceptions
for your process. This should tell you if there are unhandled
exceptions
3) Consider using FileSystemWatcher ( this is an alternative and not
really the solution to your problem)

-Sriram- Hide quoted text -

- Show quoted text -
1 - Sorry no I can't post the code,
2 - I don't have the opportunity to run perfmon on the production
server - security issues...
3 - FIleSystemWatcher is a possiblity but IMHO it has other issues
that cause problems.

Cheers

Ollie
Jun 27 '08 #4
On 23 Apr, 19:10, "sloan" <sl...@ipass.netwrote:
Check this post/thread:

http://groups.google.com/group/micro...framework/brow...

I think its best to code up a TimerCallback...
have it do the work. ... and THEN code up another call to for the timer to
fire.

You'll avoid the space time continium ordeals when your code doesn't execute
before the next time a timer (the drag and drop kind) fires again.

I think that's the best way to approach it.

I would avoid
ElapsedEventHandler

and stick with this:http://msdn2.microsoft.com/en-us/lib...ng.timercallba...

"Ollie Riches" <ollie.ric...@btinternet.comwrote in message

news:69**********************************@24g2000h sh.googlegroups.com...
I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.
The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.
The issue that is arising is intermittently files are being copied BUT
the database record is not being updated as expected AND there is no
error message in our logs. As I said this is an intermittent fault
that I can't reproduce on the development server even when I chuck a
large number of files (large file size as well) at it.
I want to know has anyone had any similar experiences.
Next step is to investigate the hardware & software configuration of
the production server.
Cheers
Ollie Riches- Hide quoted text -

- Show quoted text -
thanks but it is not a 'drag and drop' timer...

And the reason for not using Timers.Timer inside a windows service is
more a bad design than a failing in the implementation inside the
framework according to the MS KB article...

Cheers

Ollie
Jun 27 '08 #5

I realize you do not have a drag and drop timer.

I pointed you to the other thread so you could find the KB discussing it.

...

The KB also states:
Additionally, use a System.Threading.Timer object instead of the
System.Timers.Timer object.
Of course its a design issue, or it wouldn't be listed as a bug on the MS KB
article with the word "BUG" in it.
But now you know how to code around it,...which is kinda the goal of your
post, isn't it? To figure out a way to get your code to work?

...


"Ollie Riches" <ol**********@btinternet.comwrote in message
news:fa**********************************@j22g2000 hsf.googlegroups.com...
On 23 Apr, 19:10, "sloan" <sl...@ipass.netwrote:
>Check this post/thread:

http://groups.google.com/group/micro...framework/brow...

I think its best to code up a TimerCallback...
have it do the work. ... and THEN code up another call to for the timer
to
fire.

You'll avoid the space time continium ordeals when your code doesn't
execute
before the next time a timer (the drag and drop kind) fires again.

I think that's the best way to approach it.

I would avoid
ElapsedEventHandler

and stick with
this:http://msdn2.microsoft.com/en-us/lib...ng.timercallba...

"Ollie Riches" <ollie.ric...@btinternet.comwrote in message

news:69**********************************@24g2000 hsh.googlegroups.com...
I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.
The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.
The issue that is arising is intermittently files are being copied BUT
the database record is not being updated as expected AND there is no
error message in our logs. As I said this is an intermittent fault
that I can't reproduce on the development server even when I chuck a
large number of files (large file size as well) at it.
I want to know has anyone had any similar experiences.
Next step is to investigate the hardware & software configuration of
the production server.
Cheers
Ollie Riches- Hide quoted text -

- Show quoted text -

thanks but it is not a 'drag and drop' timer...

And the reason for not using Timers.Timer inside a windows service is
more a bad design than a failing in the implementation inside the
framework according to the MS KB article...

Cheers

Ollie


Jun 27 '08 #6
Note that the KB clearly states that the BUG is in v1.0 and 1.1 only and
that there is a FIX.

Willy.
"sloan" <sl***@ipass.netwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
>
I realize you do not have a drag and drop timer.

I pointed you to the other thread so you could find the KB discussing it.

..

The KB also states:
Additionally, use a System.Threading.Timer object instead of the
System.Timers.Timer object.
Of course its a design issue, or it wouldn't be listed as a bug on the MS
KB article with the word "BUG" in it.
But now you know how to code around it,...which is kinda the goal of your
post, isn't it? To figure out a way to get your code to work?

..


"Ollie Riches" <ol**********@btinternet.comwrote in message
news:fa**********************************@j22g2000 hsf.googlegroups.com...
>On 23 Apr, 19:10, "sloan" <sl...@ipass.netwrote:
>>Check this post/thread:

http://groups.google.com/group/micro...framework/brow...

I think its best to code up a TimerCallback...
have it do the work. ... and THEN code up another call to for the timer
to
fire.

You'll avoid the space time continium ordeals when your code doesn't
execute
before the next time a timer (the drag and drop kind) fires again.

I think that's the best way to approach it.

I would avoid
ElapsedEventHandler

and stick with
this:http://msdn2.microsoft.com/en-us/lib...ng.timercallba...

"Ollie Riches" <ollie.ric...@btinternet.comwrote in message

news:69**********************************@24g200 0hsh.googlegroups.com...

I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.

The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.

The issue that is arising is intermittently files are being copied BUT
the database record is not being updated as expected AND there is no
error message in our logs. As I said this is an intermittent fault
that I can't reproduce on the development server even when I chuck a
large number of files (large file size as well) at it.

I want to know has anyone had any similar experiences.

Next step is to investigate the hardware & software configuration of
the production server.

Cheers

Ollie Riches- Hide quoted text -

- Show quoted text -

thanks but it is not a 'drag and drop' timer...

And the reason for not using Timers.Timer inside a windows service is
more a bad design than a failing in the implementation inside the
framework according to the MS KB article...

Cheers

Ollie



Jun 27 '08 #7
On Apr 23, 4:29 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
Note that the KB clearly states that the BUG is in v1.0 and 1.1 only and
that there is a FIX.

Willy.

"sloan" <sl...@ipass.netwrote in message

news:%2******************@TK2MSFTNGP05.phx.gbl...
I realize you do not have a drag and drop timer.
I pointed you to the other thread so you could find the KB discussing it.
..
The KB also states:
Additionally, use a System.Threading.Timer object instead of the
System.Timers.Timer object.
Of course its a design issue, or it wouldn't be listed as a bug on the MS
KB article with the word "BUG" in it.
But now you know how to code around it,...which is kinda the goal of your
post, isn't it? To figure out a way to get your code to work?
..
"Ollie Riches" <ollie.ric...@btinternet.comwrote in message
news:fa**********************************@j22g2000 hsf.googlegroups.com...
On 23 Apr, 19:10, "sloan" <sl...@ipass.netwrote:
Check this post/thread:
>>http://groups.google.com/group/micro...framework/brow...
>I think its best to code up a TimerCallback...
have it do the work. ... and THEN code up another call to for the timer
to
fire.
>You'll avoid the space time continium ordeals when your code doesn't
execute
before the next time a timer (the drag and drop kind) fires again.
>I think that's the best way to approach it.
>I would avoid
ElapsedEventHandler
>and stick with
this:http://msdn2.microsoft.com/en-us/lib...ng.timercallba...
>"Ollie Riches" <ollie.ric...@btinternet.comwrote in message
>>news:69**********************************@24g200 0hsh.googlegroups.com...
I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.
The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.
The issue that is arising is intermittently files are being copied BUT
the database record is not being updated as expected AND there is no
error message in our logs. As I said this is an intermittent fault
that I can't reproduce on the development server even when I chuck a
large number of files (large file size as well) at it.
I want to know has anyone had any similar experiences.
Next step is to investigate the hardware & software configuration of
the production server.
Cheers
Ollie Riches- Hide quoted text -
>- Show quoted text -
thanks but it is not a 'drag and drop' timer...
And the reason for not using Timers.Timer inside a windows service is
more a bad design than a failing in the implementation inside the
framework according to the MS KB article...
Cheers
Ollie
Its hard to say anything with the limited information. From what you
have narrated in your problem, all i can make out is that the
execution is broken causing event handlers to pile up. I did not mean
to ask for the actual code; a structure of the code block is also
sufficient.

Also whats the issue with using FileSystemWatcher, which IMO is the
optimal solution.
Jun 27 '08 #8

"Ollie Riches" <ol**********@btinternet.comwrote in message
news:69**********************************@24g2000h sh.googlegroups.com...
The code C# .Net (2.0) has the required try/catch/finally to capture
any exception that might be generated during the Timer Elapsed event -
any errors that are generated are logged. I also know about the issue
relating to System.Timers.Timer swallowing unhandled exceptions. The
code also logic (locks) to prevent to Timer Elapsed event being
processed at the same time, the files are processed in a synchronous
manner.
This is why I never use Timers.Timer in a Windows Service application. I
always spawn a thread and use the Thread.Timer instead, because of the
better exception handling within them.

Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jacob Crossley | last post by:
Hello all. We have about 10 Window's services that we wrote in c#. We use them to process row's that we have queued up in various SQL tables. The services seem to hang at least once in any given...
5
by: caulker | last post by:
I have a windows service with a Timer which runs just fine on my Development machine, but the "timer_elapsed" is not being executed on the Production machine. same .exe on both machines. i'm...
3
by: Nathan Kovac | last post by:
I have a feeling I am missing something simple, but I just can't find it. Perhaps someone can give me a lead on where to look. I will describe the issue then post my code to the web service. My...
7
by: Doug Stiers | last post by:
I have a VB app that I'm installing as a Windows Service. I want a subroutine in the app to run every 30 minutes during business hours. How do I do this in VB? I set the startup type as automatic...
5
by: Tom | last post by:
Using multiple System.Timers.Timer objects in a Windows Service for performing multi-thread activities in a periodic fashion. Timers are AutoReset=false, to only have a single timer execution...
3
by: jehugaleahsa | last post by:
Hello: I have had a program that checks LDAP to get a list of all the users whose password will expire. I send these users an email letting them know to change their passwords. It had been...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.