-1

I have a Windows service which runs every 15 minutes to sync data through a HTTP REST web service. It seems to get around 128 HTTP PUTS through the couple of hundred requests and then it just stops with no errors. Is there some kind of process timeout that could be causing the issue? If so, how can I change that. I am writing each record to the EventViewer whether it passes or fails and I am not seeing any clear errors.

Chris Lombardi
  • 861
  • 2
  • 14
  • 31
  • 1
    No, there is no such limit. Chances are, it's a bug in your code. – nvoigt Mar 11 '16 at 14:00
  • Are you stopping the timer while you process, then starting it again once finished. I suspect your processing could be getting disrupted by the timer firing again before your processing is finished. Keep in mind, this is strictly a "stab in the dark" guess since you've not shown us any code. – Kevin Mar 11 '16 at 14:04
  • I thought that was the case, but I ran the code in an ASP.NET page and it worked fine. I totaled the amount of time and doubled it for the timer event to eliminate this as a problem. Because there are so many HTTP requests I am going to put each block of calls on a separate thread to see if that helps. – Chris Lombardi Mar 11 '16 at 14:09
  • @ChrisLombardi better you should debug the windows service to make sure there are no exceptions. – Kurubaran Mar 11 '16 at 14:23

1 Answers1

0

If you are using a System.Timers.Timer to execute your code, chances are that an exception is being swallowed in the elapsed handler.

Wrap your entire handler in a try catch block, and rethrow the exception on the threadpool. Something like this:

void elapsed_handler(object sender, EventArgs e)
{
    try
    {
        DoWork();
    }
    catch (Exception ex)
    {
        ThreadPool.QueueUserWorkItem(
        _ => { throw new Exception("Exception on timer thread.", ex); });
    }
}
Community
  • 1
  • 1
khargoosh
  • 1,450
  • 15
  • 40