Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OnShutdown event in a Windows Service
Message
De
30/03/2014 12:05:25
 
 
À
30/03/2014 12:01:17
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01597504
Message ID:
01597691
Vues:
25
Ok, that command takes two seconds to execute. This is why it has some kind of impact on the OnStart() event. By moving the code into the OnStart() event, this allows it to load successfully:
    Protected Overrides Sub OnStart(ByVal toArgs As String())
        oRobot.oWindowsService = Me

        ' If we cannot start
        If Not oRobot.Start() Then
            lStart = False

            ' If this from the Console application
            If Environment.UserInteractive Then
                Exit Sub
            End If

        End If

        Dim acceptedCommandsFieldInfo As System.Reflection.FieldInfo = GetType(ServiceBase).GetField("acceptedCommands", _
         System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic)
        If acceptedCommandsFieldInfo Is Nothing Then
            'Throw ApplicationException("acceptedCommands field not found")
        End If
        Dim value As Integer = CInt(acceptedCommandsFieldInfo.GetValue(Me))
        acceptedCommandsFieldInfo.SetValue(Me, value Or SERVICE_ACCEPT_PRESHUTDOWN)

        ' Define the timer
        AddHandler oTimer.Elapsed, AddressOf ServiceTimer

        ' Start the timer
        oTimer.Enabled = True

    End Sub
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform