A simple window service library for .net .
| Branch | Status |
|---|---|
| master | |
| dev | |
| release |
| Name | Stable | Preview |
|---|---|---|
| Mina |
You can install Mina via NuGet:
PM> Install-Package GodSharp.Mina
- Add a class and inherited from
MinaService, then override methodsOnInitialize,OnStart,OnStop,OnPause,OnContinue,OnCustomCommand,OnShutdown, which you need.
public class MinaSampleService:MinaService
{
public override void OnStart(string[] args)
{
}
public override void OnStop()
{
}
public override void OnPause()
{
}
public override void OnContinue()
{
}
public override void OnShutdown()
{
}
public override void OnCustomCommand(int command)
{
}
}
- Run service, you can use the following method.
MinaHost.Run(new MinaOption(),new MinaSampleService(),args);
MinaHost.Run((o)=>{},new MinaSampleService(),args);
MinaHost.Run<MinaSampleService>(new MinaOption(),args);
MinaHost.Run<MinaSampleService>((o)=>{},args);
The service install/uninstall, start/restart/pause/continue/stop, command.
The example service name is sample.exe.
Syntax:
service.exe -h[elp]
service.exe /h[elp]
Sample:
sample.exe -h
sample.exe -help
sample.exe /h
sample.exe /help
Syntax:
service.exe -i[nstall]
service.exe /i[nstall]
Sample:
sample.exe -i
sample.exe -install
sample.exe /i
sample.exe /install
Syntax:
service.exe -u[ninstall]
service.exe /u[ninstall]
Sample:
sample.exe -u
sample.exe -uninstall
sample.exe /u
sample.exe /uninstall
Syntax:
service.exe -start
service.exe /start
Sample:
sample.exe -start
sample.exe /start
Syntax:
service.exe -r[estart]
service.exe /r[estart]
Sample:
sample.exe -r
sample.exe -restart
sample.exe /r
sample.exe /restart
Syntax:
service.exe -p[ause]
service.exe /p[ause]
Sample:
sample.exe -p
sample.exe -pause
sample.exe /p
sample.exe /pause
Syntax:
service.exe -c[ontinue]
service.exe /c[ontinue]
Sample:
sample.exe -c
sample.exe -continue
sample.exe /c
sample.exe /continue
Syntax:
service.exe -stop
service.exe /stop
Sample:
sample.exe -stop
sample.exe /stop
Syntax:
service.exe -cmd|command command-parameter
service.exe /cmd|command command-parameter
command-parameter is int type.
Sample:
sample.exe -cmd 1
sample.exe -command 1
sample.exe /cmd 1
sample.exe /command 1
See sample project