Solved

Why Does a Windows Service Start and then Stop Automatically When it has Work to Do?

Posted on 2010-08-19
7
241 Views
Last Modified: 2012-05-10
This service starts a timer (System.Threading.Timer) with a start time of 1 or 0 minutes and an interval of 5 minutes. When an attempt to start it in the Services window the SCM displays the message below.

None of the App Event log messages in the code are displayed in the Application Event log window. All I see in the log is that the service was stopped with no message stating that it started. Changing the timer parameters has no effect. Another service running similar code and the same type of timer has no such problem

Can anyone point out the problem or offer some insight? Thank you for any help.

-Bob
*each function in a separate file    

Protected Overrides Sub OnStart(ByVal args() As String)
        LogEvent("Startup")
        Main()
    End Sub

    Sub Main()
        Dispacth()
    End Sub

    Public Sub Dispacth()
        LogEvent("Dispatch")
        .
        .
        StartFileAgeUpdateTimer()
    End Sub

    Public Sub StartFileAgeUpdateTimer()
        Dim StartTime As New TimeSpan(0, 1, 0) 'minutes
        Dim Interval As New TimeSpan(0, 5, 0) 'minutes
        FileAgeUpdateTimer = New System.Threading.Timer(New TimerCallback(AddressOf TimedEvent), Nothing, StartTime, Interval)
        LogEvent("Timer Started")
    End Sub

Open in new window

SCM-Message.jpg
0
Comment
Question by:bobcann
  • 4
7 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 33481625
I don't see where you actually started the timer. If the timer is not running, there is no work to do  :)
0
 

Author Comment

by:bobcann
ID: 33486070
Thanks for the response.

The timer in the other service I mentioned only needs to initialize the timer through the constructor with the start time and the interval. It runs fine. I'm doing the same with this service. The timer is initialized using TimeSpan (lines 20 & 21).

I just scoured the help files on the timer and all I as far as controlling the timer is the Dispose method, but no Start method. Also, only a few methods/prop are displayed in the drop-down list of FileAgeUpdateTimer.

I have no idea why it does not work in this service. If If there is a Start method, I can't find it.

Do you have any further thoughts on this?

Thank you.
0
 
LVL 16

Assisted Solution

by:SriVaddadi
SriVaddadi earned 250 total points
ID: 33546719
Could you post the code for TimedEvent method? I dont see it in the above snippet.

Also why cant you the StartFileAgeUpdateTimer method in the Main method why do you need a Dispatcher method again?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:bobcann
ID: 33571638
Thank you for the replies. I just got back from the hospital (week stay) and I need to re-acclimatise myself. I'll read and replay to your posts tomorrow.

Thanks again
-Bob
0
 

Author Comment

by:bobcann
ID: 33705208
Once again, sorry for my absence from this thread. Management abandoned this project.
0
 

Author Comment

by:bobcann
ID: 33719089
Please close question. Thank you.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question