title: How do I add time to a delayed task?
body: <p>I have a process where I spin up <code>FileSystemWatcher</code> to watch the filesystem for incoming files. </p>
  
  <p>I set up a delay with <code>Task.Delay</code> that cancels the FSW either when cancellation token is set or after time expires (for instance 10 minutes).</p>
  
  <pre><code>watcher.EnableRaisingEvents = true;
  
  // start the timer
  RunAfterDelay(TimeSpan.FromMinutes(10), cts.Token, () =&gt;
  {
      // get rid of the watcher
      watcher.Dispose();
  });
  
  private async void RunAfterDelay(TimeSpan delay, CancellationToken token, Action action)
  {
      await Task.Delay(delay, token);
      if (!token.IsCancellationRequested)
      {
          action();
      }
  }
  </code></pre>
  
  <p>But I'd like to configure it in a way to be able to add additional delay everytime new file appears. So effectively some kind of sliding expiration delay.</p>