title: How to pass HostControl instance to custom host service in TopShelf?
body: <p>This <a href="https://stackoverflow.com/questions/28740658/how-to-detect-if-topshelf-is-running-in-console-mode">question has been asked elsewhere on SO</a>, but there is no indication of how I get an instance of a <code>HostControl</code> as the post suggests.  My TopShelf main program looks like this:</p>
  
  <pre><code>    public static void Main()
      {
          HostFactory.Run(CreateHost);
      }
  
      private static void CreateHost(HostConfigurator x)
      {
          x.UseLog4Net();
  
          x.Service&lt;EventBroker&gt;(s =&gt;
          {
              s.ConstructUsing(name =&gt; new EventBroker());
              s.WhenStarted(tc =&gt; tc.Start());
              s.WhenStopped(tc =&gt; tc.Stop());
          });
  
          x.StartAutomatically();
  
          x.RunAsNetworkService();
      }
  </code></pre>
  
  <p>Any suggestions?</p>