Michael Stephens wrote:
I think I ran into some threading issues writing from the stream to the ui.

I can always invoke the write. In this case their are no multi-threading concerns. Did you create your own stream or use an existing one?

Michael

We wrote a callback (delegate) stream handler that we use for ironpython and some odd operations in asp.net <http://asp.net>. I wish .net made event based streams, and event based collections.
Michael Stephens

Electrical Engineering Graduate Student
University of Wyoming
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> or [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

On Mon, Jul 14, 2008 at 12:55 PM, Michael Foord <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> 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
    [email protected] <mailto:[email protected]>
    http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


------------------------------------------------------------------------

_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


--
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
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to