[IronPython] IronPython Stream

Michael Stephens falcon at uwyo.edu
Mon Jul 14 21:09:45 CEST 2008


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 asp.net.  I wish .net made event based streams, and
event based collections.
Michael Stephens

Electrical Engineering Graduate Student
University of Wyoming
falcon at uwyo.edu or 89iroc at gmail.com

On Mon, Jul 14, 2008 at 12:55 PM, Michael Foord <fuzzyman at voidspace.org.uk>
wrote:

> Hello all,
>
> 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).
>
> 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?
>
> internal class PythonStream: MemoryStream
> {
>   TextBox _output;
>   public PythonStream(TextBox textbox)
>   {
>       _output = textbox;
>   }
>
>   public override void Write(byte[] buffer, int offset, int count)
>   {
>       _output.AppendText(Encoding.UTF8.GetString(buffer, offset, count));
>   }
> }
>
>
>
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/
> http://www.trypython.org/
> http://www.ironpython.info/
> http://www.theotherdelia.co.uk/
> http://www.resolverhacks.net/
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080714/aa2ab108/attachment.html>


More information about the Ironpython-users mailing list