-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Marc Chouteau edited this page Dec 13, 2021
·
2 revisions
Generic windows services hoster, palace lauch any poco type with this caracteristics :
- Type name must terminate with "ServiceHost" suffix
Ex : SampleServiceHost
- Type must contains Initialize Method
- Type must contains Start Method
- Type must contains Stop Method
public class SampleServiceHost : IDisposable
{
private System.Timers.Timer m_Timer;
public void Initialize()
{
System.Diagnostics.Trace.WriteLine("SampleService : Initialized");
}
public void Start()
{
m_Timer = new System.Timers.Timer();
m_Timer.Interval = 2 * 1000;
m_Timer.Elapsed += (s, arg) =>
{
System.Diagnostics.Trace.WriteLine(String.Format("SampleService : {0}", DateTime.Now));
};
m_Timer.Start();
}
public void Stop()
{
m_Timer.Stop();
}
public void Dispose()
{
m_Timer = null;
}
}
Using NuGet :
PM> Install-Package Palace
Put json file (palace.json.config) on same directory of Palace.exe with this settings :
{
"ServiceName": "Palace",
"ServiceDisplayName": "Palace Services Hoster",
"ServiceDescription": "Host for services",
"ApiKey": null
}
- Reference this assembly with nuget on your Class Library Project.
- Configure build events
- Configure debug
- Run
Lauch command line tool cmd in administrator mode in installation folder
Microsoft Windows [Version 10.0.14371]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\MyService> Palace.exe /install
Microsoft Windows [Version 10.0.14371]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\MyService> Palace.exe /uninstall
Palace run with "Network Service" account