I think I ran into some threading issues writing from the stream to the ui.&nbsp; We wrote a callback (delegate) stream handler that we use for ironpython and some odd operations in <a href="http://asp.net">asp.net</a>.&nbsp; I wish .net made event based streams, and event based collections.<br clear="all">
Michael Stephens<br><br>Electrical Engineering Graduate Student<br>University of Wyoming<br><a href="mailto:falcon@uwyo.edu">falcon@uwyo.edu</a> or <a href="mailto:89iroc@gmail.com">89iroc@gmail.com</a>
<br><br><div class="gmail_quote">On Mon, Jul 14, 2008 at 12:55 PM, Michael Foord &lt;<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello all,<br>
<br>
I&#39;m diverting the standard ouput and standard error streams on a Python engine. I would like to provide a Stream that executes a callback on every write (rather than just collecting output as most of the examples show).<br>

<br>
Inheriting from &#39;Stream&#39; is easy but requires implementing a tedious number of methods and properties. Inheriting from &#39;MemoryStream&#39; and only overriding &#39;Write&#39; (plus the constructor) works fine. I&#39;m wondering if it is &#39;correct&#39;? It is probably an abuse of MemoryStream - can this approach fail?<br>

<br>
internal class PythonStream: MemoryStream<br>
{<br>
 &nbsp; TextBox _output;<br>
 &nbsp; public PythonStream(TextBox textbox)<br>
 &nbsp; {<br>
 &nbsp; &nbsp; &nbsp; _output = textbox;<br>
 &nbsp; }<br>
<br>
 &nbsp; public override void Write(byte[] buffer, int offset, int count)<br>
 &nbsp; {<br>
 &nbsp; &nbsp; &nbsp; _output.AppendText(Encoding.UTF8.GetString(buffer, offset, count));<br>
 &nbsp; }<br>
}<br>
<br>
<br>
<br>
-- <br>
<a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a><br>
<a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a><br>
<a href="http://www.trypython.org/" target="_blank">http://www.trypython.org/</a><br>
<a href="http://www.ironpython.info/" target="_blank">http://www.ironpython.info/</a><br>
<a href="http://www.theotherdelia.co.uk/" target="_blank">http://www.theotherdelia.co.uk/</a><br>
<a href="http://www.resolverhacks.net/" target="_blank">http://www.resolverhacks.net/</a><br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</blockquote></div><br>