Created
May 2, 2017 16:57
-
-
Save agross/33f61d074bde09a4e5e1e88ec35541c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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