Solved

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

Posted on 2010-08-19
7
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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