I think I ran into some threading issues writing from the stream to the ui. 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>. 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 <<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>> 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'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 'Stream' is easy but requires implementing a tedious number of methods and properties. Inheriting from 'MemoryStream' and only overriding 'Write' (plus the constructor) works fine. I'm wondering if it is 'correct'? It is probably an abuse of MemoryStream - can this approach fail?<br>
<br>
internal class PythonStream: MemoryStream<br>
{<br>
TextBox _output;<br>
public PythonStream(TextBox textbox)<br>
{<br>
_output = textbox;<br>
}<br>
<br>
public override void Write(byte[] buffer, int offset, int count)<br>
{<br>
_output.AppendText(Encoding.UTF8.GetString(buffer, offset, count));<br>
}<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>