?
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
?
246 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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