Multiple Instances of same Application as a Windows Service?

前端 未结 2 1333
[愿得一人]
[愿得一人] 2021-02-14 23:05

I have an application that manages the heavy processing for my project, and need to convert it to a \"Windows Service.\" I need to allow running multiple versions

相关标签:
2条回答
  • 2021-02-14 23:43

    Though I can't answer your questions specific to option #1, I can tell you that option #2 worked very well for us. We wanted to create an app domain for each 'child' service to run under and for each of them to use a different configuration file. In our service's config file we stored the app domains to start and the configuration file to use. So for each entry we simply created the app domain, set the configuration file etc and off we went. This separation of configuration allowed us to easily specify the ports and log file locations uniquely for each instance. Of additional benefit to us was that we wrote our 'child service' as a command-line exe and simply called the AppDomain's ExecuteAssembly() on a new thread for each 'child' service. The only 'clunk' in the solution was shutdown, we didn't bother to create a 'good' solution for it.

    Update Feb, 2012

    Some time ago we started using 'named' services (like SQL Server). I detailed the entire process on my blog in a series "Building a Windows Service – Part 1 through Part 7". They take you through creating a command-line/windows service hybrid complete with self-installation. The following goals where met:

    • Building a service that can also be used from the console
    • Proper event logging of service startup/shutdown and other activities
    • Allowing multiple instances by using command-line arguments
    • Self installation of service and event log
    • Proper event logging of service exceptions and errors
    • Controlling of start-up, shutdown and restart options
    • Handling custom service commands, power, and session events
    • Customizing service security and access control

    A complete Visual Studio project template is available in the last article of the series Building a Windows Service – Part 7: Finishing touches.

    0 讨论(0)
  • 2021-02-14 23:49

    Check this out: Multiple Instance .NET Windows Service

    0 讨论(0)
提交回复
热议问题