I’m working on a program the uses an EXEC command to run a make file. This can take a long time so I want to put it in the background so the GUI doesn’t lock up. However I also want the GUI to be disabled and a progress bar to run only while the make file is compiling.
So how can I detect when a background progress has finished in TCL?
Edit: It gets more complicated because my boss wants the command window to stay open (or be visable) so the user can see the progress of the make and see if it errors.
P.S. Would figuring out threading be easier? I need some way to prevent the GUI from locking up (prevent NOT RESPONDING).’
Edit: The GUI is made with TK.
I think TK is single-threaded which causes the problem. Or it could be that it defaults to single threaded and I want to set it to multi-thread.
As @glenn-jackman pointed out, the use of fileevent is preferred (because it should work everywhere).
Invoke this as
bgexec job_done cmd /c start /wait cmd /c make all-all.job_donegets called with the output of the command after it finishes.It is also possible to use threads for this things, but this requires a threaded tcl build (which is now default for all platforms AFAIK, but older versions of Tcl esp. under unix don’t build a threaded Tcl by default.) and the
Threadpackage (which is included by default). An approach to use it with Threads would be:If you need to call this on a regular basis it might be worth to use only one worker thread instead of creating a new one for each job.
Edit: Add
/waitas parameter for start the keep the first cmd running.