title: anonymous delegates in C#
body: <p>I can't be the only one getting tired of defining and naming a delegate for just a single call to something that requires a delegate. For example, I wanted to call .Refresh() in a form from possibly other threads, so I wrote this code:</p>
  
  <pre><code>private void RefreshForm()
  {
      if (InvokeRequired)
          Invoke(new InvokeDelegate(Refresh));
      else
          Refresh();
  }
  </code></pre>
  
  <p>I'm not even sure I have to, I just read enough to be scared that it won't work at some later stage.<br>
  InvokeDelegate is actually declared in another file, but do I <em>really</em> need an entire delegate dedicated just for this? aren't there any generic delegates at all?<br>
  I mean, for example, there's a Pen class, but there's also Pens.<em>pen-of-choice</em> so you don't have to remake the whole thing. It's not the same, but I hope you understand what I mean.</p>