title: How to Asynchronously read MemoryStream
body: <p>I am writing an application which involves IronRuby.  I would like to update a UI element when I receive output from my ruby script, so I have set up the following:</p>
  
  <pre><code>var ScriptEngine engine = IronRuby.Ruby.CreateEngine();
  MemoryStream outputStream = new MemoryStream();
  engine.Runtime.IO.SetOutput(outputStream, Encoding.Default);
  </code></pre>
  
  <p>This redirects the output of IronRuby to a custom stream called <code>outputStream</code>.  However, I cannot seem to figure out how to call a block of code once the stream receives new information.  How could I do the equivalent of the following?</p>
  
  <pre><code>outputStream.DataReceived += (sender, e) =&gt;
  {
      // assumes I passed in the Func `processing` to my method
      processing(e.Value);
  };
  </code></pre>
  
  <p>Thanks!</p>