Solved

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

Posted on 2010-08-19
7
239 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 74

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now