On Friday, October 8, 2021 at 3:27:44 PM UTC-7, Christian Werner wrote:
So how the threads are created in the tcl script when run from blocking in a channel read operations i tclsh.exe (? Where is the event loop started in this case?
Assuming, that you're executing a script which does some thread creation at the end you'll have to do a "vwait forever", otherwise your main script terminates.
In your situation, you could read a little script containing "vwait forever" from is.input in order to have your event loop.
Christian ,
Thanks, for help. I was confused about how tcl loop works.
I am not sure your suggestion would work for me, since "vwait forever" would disable the user input in the terminal.
Let me try to explain what I try to achieve.
Even though I am forced to start TCL in the secondary thread , it is just to fight the inability of Qt to run widgets in the secondary thread.
But most likely our application will ever have 2 threads. TCl Loop is created from QT as soon application starts, but QT (primary application thread ) will basically do nothing else unless "show_gui" command is executed.
All the tcl commands should be executed in the single tcl thread in the blocking manner ( if command is long running - it creates threads as needed , but they are not controlled from tcl)
Since tcl is how application is started and GUI might not be even shown we want the terminal code behave exactly the same way as with tclsh.exe.
So I am trying to use original Tcl_MainEx.
And the only problem I still can't solve - how to pass script from Qt to Tcl. (Tcl to Qt communication will be synchronized when commands are executed using Qt mechanics)
As far as I understand I have 2 option:
1. set custom TclGetMainLoop procedure which will wait for either text typed by user in the terminal or receive text from ui.
2. write my own stream (basically std::in with the ability to write to it) and set it as an input channel.
Hope this makes sense.
And thanks again,
Alex
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)