title: Delegate with parameters... as a parameter
body: <p>I have this method with its delegate that is used to append text to a multiline TextBox in the GUI from any of the threads in my WinForms application:</p>
  
  <pre><code>private delegate void TextAppendDelegate(TextBox txt, string text);
  public void TextAppend(TextBox txt, string text)
  {
    if(txt.InvokeRequired)
      txt.Invoke(new TextAppendDelegate(TextAppend), new object[] {txt, text });
    else
    {
      if(txt.Lines.Length == 1000)
      {
        txt.SelectionStart = 0;
        txt.SelectionLength = txt.Text.IndexOf("\n", 0) + 1;
        txt.SelectedText = "";
      }
      txt.AppendText(text + "\n");
      txt.ScrollToCaret();
    }
  }
  </code></pre>
  
  <p>It works great, I just call TextAppend(myTextBox1, "Hi Worldo!") from any thread and the GUI is updated. Now, is there some way to pass a delegate that invokes TextAppend to one of my utility methods in another project without sending any reference to the actual TextBox, something that might look like this from the caller:</p>
  
  <pre><code>Utilities.myUtilityMethod(
      new delegate(string str){ TextAppend(myTextBox1, str) });
  </code></pre>
  
  <p>And in the callee, a definition similar to:</p>
  
  <pre><code>public static void myUtilityMethod(delegate del)
  {
      if(del != null) { del("Hi Worldo!"); }
  }
  </code></pre>
  
  <p>So that when this function is called, it invokes the TextAppend method with that string and the predefined TextBox the caller wants to use. Is this possible or am I crazy? I know there are way easier options like using interfaces or passing the TextBox and delegate, but I want to explore this solution because it seems more elegant and hides stuff from the callee. The problem is that I'm still too novice in C# and barely understand delegates, so please help me with the actual syntax that would work.</p>
  
  <p>Thanks in advance!</p>