Skip to content

Instantly share code, notes, and snippets.

@agross
Created May 2, 2017 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agross/33f61d074bde09a4e5e1e88ec35541c6 to your computer and use it in GitHub Desktop.
Save agross/33f61d074bde09a4e5e1e88ec35541c6 to your computer and use it in GitHub Desktop.
public class Program
{
public static void Main(string[] args)
{
HostFactory.Run(x =>
{
x.Service<ClassThatHasStartAndStopMethods>(s =>
{
// optional, when you want an IoC to resolve deps.
s.ConstructUsing(settings => new MefBootstrapper(settings).Root);
s.WhenStarted((managedUc, hc) =>
{
// managedUc is an instance of ClassThatHasStartAndStopMethods
managedUc.Start(hc);
return true;
});
s.WhenStopped(managedUc => managedUc.Stop());
});
x.RunAsNetworkService();
x.StartAutomaticallyDelayed();
x.SetDescription("some description");
x.SetDisplayName("Managed UC");
x.SetServiceName("ManUC");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment