Skip to content

Instantly share code, notes, and snippets.

@scottlittlewood
Last active August 29, 2015 14:08
Show Gist options
  • Save scottlittlewood/8e956cc18136fe6670b1 to your computer and use it in GitHub Desktop.
Save scottlittlewood/8e956cc18136fe6670b1 to your computer and use it in GitHub Desktop.
public class Program
{
public static void Main(string[] args)
{
var serviceNamespace = typeof (Service).Namespace;
HostFactory.Run(x =>
{
x.Service<IService>(s =>
{
s.ConstructUsing(n => new Service());
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
});
x.RunAsLocalSystem();
x.SetDescription(serviceNamespace);
x.SetDisplayName(serviceNamespace);
x.SetServiceName(serviceNamespace);
});
}
}
public interface IService
{
void Start();
void Stop();
}
public class Service : IService
{
public void Start()
{
}
public void Stop()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment