title: Automatically unsubscribe an event
body: <p>Is it possible to do something like this in C#?  Probably with Expressions.
  The EventHandlers are not members of a Control or any class that I own.</p>
  
  <p>E.g.:</p>
  
  <pre><code>Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);
  </code></pre>
  
  <p>The EventHandler is a static reference that I don't own.  How can I pass that type of statement to the following function?</p>
  
  <pre><code>private void RegisterEvent(EventHandler handler, Action&lt;EventArgs&gt; action)
  {
     handler += action;
     m_toUnsubscribe.Add(handler, action);
  }
  
  ... in Dispose()
  {
    foreach(var pair in m_toUnsubscribe)
    {
      pair.handler -= pair.action;
    }
  }
  </code></pre>