title: Create and schedule jobs at runtime in .Net MVC
body: <p>I want to create a Report Scheduler to send the email with attach report automatically based on timings defined by User.</p>
  
  <p>User can specify the Time and Occurrence of Report, once it is saved scheduler need to run on that specific time/day based on settings defined, also every user is independent to define its own settings.</p>
  
  <p>I had taken reference from below SO answer</p>
  
  <p><a href="https://stackoverflow.com/questions/41589865/how-to-reschedule-quartz-job-scheduler-in-c-sharp-dynamically-from-database">How to reschedule Quartz job scheduler in C# dynamically from database?</a></p>
  
  <pre><code>/// &lt;summary&gt;
  /// Create a new trigger based on a existing trigger.
  /// &lt;/summary&gt;
  /// &lt;param name="oldTrigger"&gt;the existing trigger&lt;/param&gt;
  /// &lt;param name="startNow"&gt;indicates if the trigger should start immediately after schedule&lt;/param&gt;
  /// &lt;param name="interval"&gt;the interval for the new trigger&lt;/param&gt;
  /// &lt;returns&gt;Returns the new trigger&lt;/returns&gt;
  public ITrigger CreateTrigger(ITrigger oldTrigger, bool startNow = false, TimeSpan? interval = null)
  {
      var builder = oldTrigger.GetTriggerBuilder();
      if (startNow)
          builder = builder.StartNow();
      if (interval.HasValue)
          builder = builder.WithSimpleSchedule(s =&gt; s
              .WithInterval(interval.Value)
              .RepeatForever());
  
      var newTrigger = builder.Build();
      var simpleTrigger = newTrigger as ISimpleTrigger;
      if(simpleTrigger != null)
      {
          var trigger = oldTrigger as ISimpleTrigger;
          if (trigger != null)
              simpleTrigger.TimesTriggered = trigger.TimesTriggered;
      }
  
      return newTrigger;
  }
  </code></pre>
  
  <p>How to use it</p>
  
  <pre><code>In this example, the Scheduler is already running.
  // get the trigger
  var trigger = Scheduler.GetTrigger(new TriggerKey("trigger1", "group1"));
  
  // get your settings and set the interval
  var reminderSettings = GetReminderSettings();
  var intervalBtwnReminders = 0;
  if (reminderSettings?.RemindersGap != null)
  {
      intervalBtwnReminders = (int)(reminderSettings.RemindersGap);         
  }
  
  // reschedule the job with a new trigger and start it immediately.
  // if you don't want that it starts now, pass 'false' for the 'startNow' parameter
  Scheduler.RescheduleJob(trigger.Key, CreateTrigger(trigger, true, TimeSpan.FromMinutes(intervalBtwnReminders)));
  </code></pre>
  
  <p><strong>Questions :</strong></p>
  
  <p>Above code shows for rescheduling the job but i want to create new scheduler every time user saves.</p>
  
  <p>what if two users defined same timing then also Quartz.Net work for both?</p>
  
  <p>is there any better approach available or is there any performance issue with this approach?</p>