title: Pass configuration to IHostedService
body: <p>I'm trying to add a configuration value to an <code>IHostedService</code> but do not know how.</p>
  
  <p>This is what I have at the moment:</p>
  
  <p>Startup</p>
  
  <pre><code>services.Configure&lt;MyOptions&gt;(Configuration.GetSection("MyOptions"));
  services.AddHostedService&lt;MyHostedService&gt;();
  </code></pre>
  
  <p>MyOptions</p>
  
  <pre><code>public class MyOptions
  {
      public string MyOption{ get; set; }
  }
  </code></pre>
  
  <p>Appsettings</p>
  
  <pre><code>"MyOptions": {
    "MyOption": "42"
  }
  </code></pre>
  
  <p>MyHostedService</p>
  
  <pre><code>public MyHostedService(ILogger&lt;MyHostedService&gt; logger)
  {
      _logger = logger;
      // Where are my options?! :(
  }
  </code></pre>