title: WPF inactivity and activity
body: <p>I'm trying to handle user inactivity and activity in a WPF application to fade some stuff in and out. After a lot of research, I decided to go with the (at least in my opinion) very elegant solution Hans Passant posted <a href="https://stackoverflow.com/questions/2363117/shutdown-wpf-application-after-n-seconds-of-inactivity/2363364#2363364">here</a>.</p>
  
  <p>There's only one downside: As long as the cursor stays on top of the window, the <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.inputmanager.preprocessinput.aspx" rel="noreferrer"><code>PreProcessInput</code></a> event gets continously fired. I'm having a full-screen application, so this kills it. Any ideas how I can bypass this behaviour would be most appreciated.</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      readonly DispatcherTimer activityTimer;
  
      public MainWindow()
      {
          InitializeComponent();
  
          InputManager.Current.PreProcessInput += Activity;
  
          activityTimer = new DispatcherTimer
          {
              Interval = TimeSpan.FromSeconds(10),
              IsEnabled = true
          };
          activityTimer.Tick += Inactivity;
      }
  
      void Inactivity(object sender, EventArgs e)
      {
          rectangle1.Visibility = Visibility.Hidden; // Update
          // Console.WriteLine("INACTIVE " + DateTime.Now.Ticks);
      }
  
      void Activity(object sender, PreProcessInputEventArgs e)
      {
          rectangle1.Visibility = Visibility.Visible; // Update
          // Console.WriteLine("ACTIVE " + DateTime.Now.Ticks);
  
          activityTimer.Stop();
          activityTimer.Start();
      }
  }
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>I could narrow down the described behaviour better (see the <code>rectangle1.Visibility</code> update in the above code). As long as the cursor rests on top of the window and for example the <code>Visibility</code> of a control is changed, the <code>PreProcessInput</code> is raised. Maybe I'm misunderstanding the purpose of the <code>PreProcessInput</code> event and when it fires. MSDN wasn't very helpful here.</p>