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:
var ScriptEngine engine = IronRuby.Ruby.CreateEngine();
MemoryStream outputStream = new MemoryStream();
engine.Runtime.IO.SetOutput(outputStream, Encoding.Default);
This redirects the output of IronRuby to a custom stream called outputStream
. 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?
outputStream.DataReceived += (sender, e) =>
{
// assumes I passed in the Func `processing` to my method
processing(e.Value);
};
Thanks!