override public void Run() { if (debug) { WriteLine("entered ConsoleThread run() method"); } put(out_Renamed, "% "); while (true) { // Loop forever to collect user inputs in a StringBuffer. // When we have a complete command, then execute it and print // out the results. // // The loop is broken under two conditions: (1) when EOF is // received inside getLine(). (2) when the "exit" command is // executed in the script. getLine(); string command = sbuf.ToString(); if (debug) { WriteLine("got line from console"); WriteLine("\"" + command + "\""); } // When interacting with the interpreter, one must // be careful to never call a Tcl method from // outside of the event loop thread. If we did // something like just call interp.eval() it // could crash the whole process because two // threads might write over each other. // The only safe way to interact with Tcl is // to create an event and add it to the thread // safe event queue. AnonymousClassTclEvent Tevent = new AnonymousClassTclEvent(command, this); // end TclEvent innerclass // Add the event to the thread safe event queue interp.getNotifier().queueEvent(Tevent, TCL.QUEUE_TAIL); // Tell this thread to wait until the event has been processed. Tevent.sync(); } }
override public void Run() { if (debug) { WriteLine("entered ConsoleThread run() method"); } put(out_Renamed, "% "); while (true) { // Loop forever to collect user inputs in a StringBuffer. // When we have a complete command, then execute it and print // out the results. // // The loop is broken under two conditions: (1) when EOF is // received inside getLine(). (2) when the "exit" command is // executed in the script. getLine(); string command = sbuf.ToString(); if (debug) { WriteLine("got line from console"); WriteLine("\"" + command + "\""); } // When interacting with the interpreter, one must // be careful to never call a Tcl method from // outside of the event loop thread. If we did // something like just call interp.eval() it // could crash the whole process because two // threads might write over each other. // The only safe way to interact with Tcl is // to create an event and add it to the thread // safe event queue. TclEvent Tevent = new AnonymousClassTclEvent(command, this); // end TclEvent innerclass // Add the event to the thread safe event queue interp.getNotifier().queueEvent(Tevent, TCL.QUEUE_TAIL); // Tell this thread to wait until the event has been processed. Tevent.sync(); } }