title: Using FluentScheduler - ASP.NET Core MVC
body: <p>I currently have a simple website setup with ASP.NET Core MVC (.NET 4.6.1), and I would like to periodically do some processes like automatically send emails at the end of every day to the registered members.</p>
  
  <p>After doing some searching, I came across two common solutions - Quartz.NET and FluentScheduler.</p>
  
  <p>Based on this <a href="https://stackoverflow.com/questions/41821568/how-to-start-quartz-in-asp-net-core">SO thread</a>, I found the approach of using FluentScheduler more easier to digest and use for my simple task. After quickly implementing the following lines of code into my Program.cs class, I had the emails going out successfully every minute (for testing purposes).</p>
  
  <pre><code>public class Program
  {
      public static void Main(string[] args)
      {
          var host = new WebHostBuilder()
              .UseKestrel()
              .UseContentRoot(Directory.GetCurrentDirectory())
              .UseIISIntegration()
              .UseStartup&lt;Startup&gt;()
              .Build();
  
              var registry = new Registry();
              JobManager.Initialize(registry);
  
              JobManager.AddJob(() =&gt; MyEmailService.SendEmail(), s =&gt; s
                    .ToRunEvery(1)
                    .Minutes());
  
              host.Run();
  
      }
  }
  </code></pre>
  
  <p>However, now apart from sending emails I also need to do some back-end processing for e.g. updating the user records in the DB when mails are being sent out. For this, I normally inject my Entity Framework Context into the constructor of my controllers and use it to get/update SQL records.</p>
  
  <p>My question is, since I cannot really inject these services into the main method, where would be the appropriate place to initialize the registry and add jobs for scheduling?</p>
  
  <p>Thanks for the help, I am a little new to this so a little guidance would be much appreciated!</p>