Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sub classing a Windows Service
Message
De
31/08/2013 14:37:39
 
 
À
27/08/2013 11:25:49
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:
01581512
Message ID:
01581767
Vues:
36
Not easy to do but one approach is to drop the designer pre-generated classes and do a simple class of your own.

So, this would be at the framework level:
Imports System.ServiceProcess

Public Class WindowsService
    Inherits ServiceBase

    Protected Shared Sub Startup(toArgs As String(), toWindowsService As WindowsService, tlInteractiveWait As Boolean)

        If toWindowsService Is Nothing Then
            Throw New ArgumentNullException("instance")
        End If

        If Environment.UserInteractive Then
            toWindowsService.OnStart(toArgs)

            If tlInteractiveWait Then
                Console.WriteLine("Press any key to stop service")
                Console.ReadKey()
            End If

            toWindowsService.OnStop()
        Else
            Run(toWindowsService)
        End If

    End Sub
And, this at the client level:
Public Class Main
    Inherits Framework.WindowsService

    Public Sub New()
        ServiceName = System.Configuration.ConfigurationManager.AppSettings("MyServiceName")
    End Sub

    Public Shared Sub Main(toArgs As String())
        Startup(toArgs, New Main(), True)
    End Sub

    Protected Overrides Sub OnStart(toArgs As String())
        MyBase.OnStart(toArgs)
    End Sub

    Protected Overrides Sub OnStop()
        MyBase.OnStop()
    End Sub

End Class
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