Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
.NET windows service freeze
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01595318
Message ID:
01595602
Views:
52
Multi-threaded code can be difficult to debug. Timers fire on another thread so effectively your code is multi-threaded. If you update any sort of UI or main thread controls it's easy to create exceptions. Make sure the data you're working with is thread safe.

The other thing is if an exception occurs on the non-main thread, .NET just eats that exception. So if something goes wrong in your timer code and you're not capturing the error in the timer's execution then the error just disappears without notice. If you have exception handling and you want to capture errors make sure you do it INSIDE of the timer code and then log that.

Hope this helps,

+++ Rick ---

>Hi
>I am using C# .NET 3.5 to develop my windows service. It is customized task scheduler. I have code to write log to text file for every threading.timer event fired. I have problem that, my windows service would freeze after run sometime. From my log, the last logging was executed few days ago. I try to restart it and it working fine again. I have TRY...CATCH... to capture all exception but no exception captured.
>
>Recently, I added more code to log, but this time to event viewer. The weird thing is, it is working till today.
>
>Any ideas?
>
>Thank you
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Reply
Map
View

Click here to load this message in the networking platform