title: Countdown timer increase on interaction?
body: <p>I have a form that I want to close after 5 seconds if no mouse interaction is done but if any mouse interaction is done I want it to close <code>countdown + 5 seconds</code> and each interaction would increase it by 5 seconds.</p>
  
  <p>This is what I came up with so far:</p>
  
  <pre><code>int countdown = 5;
  System.Timers.Timer timer;
  </code></pre>
  
  <p>Start timer</p>
  
  <pre><code>timer = new System.Timers.Timer(1000);
  timer.AutoReset = true;
  timer.Elapsed += new System.Timers.ElapsedEventHandler(ProcessTimerEvent);
  timer.Start();
  </code></pre>
  
  <p>The event</p>
  
  <pre><code>private void ProcessTimerEvent(Object obj, System.Timers.ElapsedEventArgs e)
  {
      --countdown;
      if (countdown == 0)
      {
          timer.Close();
          this.Invoke(new Action(() =&gt; { this.Close(); }));
      }
  }
  </code></pre>
  
  <p>And just for testing I am using the form mouseclick event to increaes the countdown by 5 but will have to change it to a a different event because if you click on a label or any other control on the form it will not increase the timer.</p>
  
  <pre><code>private void NotifierTest_MouseClick(object sender, MouseEventArgs e)
  {
      countdown += 5;
  }
  </code></pre>
  
  <hr>
  
  <h1>Questions</h1>
  
  <ul>
  <li><p>Am I implementing a countdown where
  the counter can be increased in a
  correct way ?</p></li>
  <li><p>Should I change anything ?</p></li>
  <li><p>How would you do this if any different from what I have done ?</p></li>
  <li><p>How should I handle the mouse click
  capture ?</p></li>
  <li><p>Using a Low Level Hook ?</p></li>
  <li><p>Using mouse click position and verify
  if it was or not on my winform ?</p></li>
  </ul>
  
  <h1>Other option</h1>
  
  <p>A different option I am currently thinking is to capture if the mouse is within the form area or not and enable / disable the close countdown if it is not within the area but I am not sure on how to interact with the mouse for this hence the above questions about how would I interact with the mouse.</p>