Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-08-19
7
Medium Priority
?
247 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 1000 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Loops Section Overview

610 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