title: One shot events using Lambda in C#
body: <p>I find myself doing this sort of thing quite often:-</p>
  
  <pre><code> EventHandler eh = null;  //can't assign lambda directly since it uses eh
   eh = (s, args) =&gt;
   {
       //small snippet of code here
  
       ((SomeType)s).SomeEvent -= eh;
   }
   variableOfSomeType.SomeEvent += eh;
  </code></pre>
  
  <p>Basically I only want to attach an event handler to listen for one shot from the event, I no longer want to stay attached after that.  Quite often that "snippert of code" is just one line.</p>
  
  <p>My mind is going a bit numb, I'm sure there must be something I can do so I don't need to repeat all this overhead.  Bear in mind that <code>EventHandler</code> may well be <code>EventHandler&lt;T&gt;</code>.</p>
  
  <p>Any ideas how I can tidy up the repeative part of the code and just leave the snippet in a Lambda?</p>