From 5d94b26f4e47504f3c090937fac219a8ea39abcc Mon Sep 17 00:00:00 2001 From: PeterKottas Date: Thu, 29 Dec 2016 08:09:06 +0100 Subject: [PATCH] Added extra arguments to service start method --- Source/PeterKottas.DotNetCore.Example/Program.cs | 3 ++- .../Configurators/Service/ServiceConfigurator.cs | 3 ++- .../PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs | 2 +- .../PeterKottas.DotNetCore.WindowsService.nuspec | 2 +- Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/PeterKottas.DotNetCore.Example/Program.cs b/Source/PeterKottas.DotNetCore.Example/Program.cs index c227d03..cf33442 100644 --- a/Source/PeterKottas.DotNetCore.Example/Program.cs +++ b/Source/PeterKottas.DotNetCore.Example/Program.cs @@ -19,7 +19,8 @@ public static void Main(string[] args) { return new ExampleServiceTimer(); }); - serviceConfig.OnStart(service => + + serviceConfig.OnStart((service, extraParams) => { Console.WriteLine("Service {0} started", name); service.Start(); diff --git a/Source/PeterKottas.DotNetCore.WindowsService/Configurators/Service/ServiceConfigurator.cs b/Source/PeterKottas.DotNetCore.WindowsService/Configurators/Service/ServiceConfigurator.cs index 32a39db..0dd2dbf 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/Configurators/Service/ServiceConfigurator.cs +++ b/Source/PeterKottas.DotNetCore.WindowsService/Configurators/Service/ServiceConfigurator.cs @@ -1,5 +1,6 @@ using PeterKottas.DotNetCore.WindowsService.Interfaces; using System; +using System.Collections.Generic; namespace PeterKottas.DotNetCore.WindowsService.Configurators.Service { @@ -16,7 +17,7 @@ public void ServiceFactory(Func serviceFactory) config.ServiceFactory = serviceFactory; } - public void OnStart(Action onStart) + public void OnStart(Action> onStart) { config.OnServiceStart = onStart; } diff --git a/Source/PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs b/Source/PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs index 80086f0..a31fde2 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs +++ b/Source/PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs @@ -33,7 +33,7 @@ public HostConfiguration() public Func ServiceFactory { get; set; } - public Action OnServiceStart { get; set; } + public Action> OnServiceStart { get; set; } public Action OnServiceStop { get; set; } diff --git a/Source/PeterKottas.DotNetCore.WindowsService/PeterKottas.DotNetCore.WindowsService.nuspec b/Source/PeterKottas.DotNetCore.WindowsService/PeterKottas.DotNetCore.WindowsService.nuspec index fa7598a..826676d 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/PeterKottas.DotNetCore.WindowsService.nuspec +++ b/Source/PeterKottas.DotNetCore.WindowsService/PeterKottas.DotNetCore.WindowsService.nuspec @@ -3,7 +3,7 @@ PeterKottas.DotNetCore.WindowsService PeterKottas.DotNetCore.WindowsService - 1.0.3 + 1.0.4 Peter Kottas Easiest to use library that allows one to host .net core as windows services there is. .NET Core Windows service diff --git a/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs b/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs index a7be663..979add3 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs +++ b/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs @@ -244,7 +244,7 @@ private static void Start(HostConfiguration config) { try { - config.OnServiceStart(config.Service); + config.OnServiceStart(config.Service, config.ExtraArguments); } catch (Exception e) {