using System.ServiceProcess; using EPServiceProviderLibrary; public partial class MyService : ServiceBase { private EPServiceProvider _epService; protected override void OnStart(string[] args) { // Create and start the EPServiceProvider _epService = new EPServiceProvider(); _epService.Start(); // Register any event handlers or subscribers // ... // Do other startup work // ... } protected override void OnStop() { // Dispose of the EPServiceProvider and any other services it depends on _epService.Dispose(); } }
using EPServiceProviderLibrary; class Program { static void Main(string[] args) { // Create and start the EPServiceProvider using (var epService = new EPServiceProvider()) { epService.Start(); // Register any event handlers or subscribers // ... // Do work // ... // Dispose of the EPServiceProvider and any other services it depends on epService.Dispose(); } } }Package library: EPServiceProviderLibrary.