title: How to make a function that blocks until it has data to return in c#
body: <p>How do I make a custom function that returns output and blocks until output is available? I'm thinking of something like <code>Console.ReadLine()</code>. Something like this:</p>
  
  <pre><code>var resp = Output(); //blocks until output is sent.
  ...
  //returns a string once SendOutput is called and hands over the string.
  public static string Output() { /* what goes here? */ }
  //Is this function even needed? Can I just fire Output somehow?
  private static string SendOutput(string msg) { /* what goes here? */ }
  ...
  //Calls sendoutput with the string to send.
  SendOutput(msg);
  </code></pre>
  
  <p>Basically I'm making a listener that is blocked until it gets data (like it would if calling <code>console.readline</code>), and I need the internal code to make the blocker. </p>