>I think the issue is related to the Windows Service does not wait for the timer. For example, if I execute it from the EXE, I can see a message box at the end showing a message that tells me that the OnStop() event was reached. So, while the message is showing, I can see the executable in the Task manager. Then, I click ok and the OnStop() finishes making the executable to complete and it goes out of the Task manager.
>
>So, from the Services interface or from the sc command, I believe for the windows service to properly run, it has to fall into the wait step for the timer to kick in. But, this does not seem to happen as, even if the timer is activated at the end of the OnStart() event, it falls right away in the OnStop() event making the executable to disappear from the memory. This is what I can see from the Task manager.
>
>My Main class is like this:
>
>
>Public Class Main
> Inherits WindowsService
>
> Shared Sub Main(ByVal toArgs As String())
> Startup(toArgs, New Main(), True)
> End Sub
>
>
>And, the base class:
>
>
>Imports System.ServiceProcess
>
>Public Class WindowsService
> Inherits ServiceBase
>
> Public oTimer As New System.Timers.Timer(5000)
>
> Protected Shared Sub Startup(toArgs As String(), toWindowsService As WindowsService, tlInteractiveWait As Boolean)
> toWindowsService.OnStart(toArgs)
> End Sub
>
> Protected Overrides Sub OnStart(ByVal toArgs As String())
> MyBase.OnStart(toArgs)
>
> ' Define the timer
> AddHandler oTimer.Elapsed, AddressOf ServiceTimer
>
> ' Start the timer
> oTimer.Enabled = True
>
> System.Windows.Forms.MessageBox.Show("End")
> End Sub
>
> Protected Overrides Sub OnStop()
> MyBase.OnStop()
> End Sub
>
> Private Sub ServiceTimer(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs)
> End Sub
>
Maybe the UI is the issue. From the Wikipedia article:
"Prior to Windows Vista, services installed as an "interactive service" could interact with Windows desktop and show a graphical user interface. In Windows Vista, however, interactive services are deprecated and may not operate properly, as a result of Windows Service hardening."
http://en.wikipedia.org/wiki/Security_and_safety_features_new_to_Windows_Vista#Windows_Service_Hardening
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up