What, what, whaaat?
Are there any SampleScripts that do that for you? Let us know and we will have a closer look.
Petr
Hi All
sometimes i test examples which does not exit correctly, and the thinbasic.exe still running in the background. i don't like going to task manager with ctrl+alt+del and then searching the long list for thinbasic.exe . so googling and i find the solution:
http://superuser.com/questions/91478...ine-in-windows
from the command prompt:
TASKLIST /FI "IMAGENAME eq thinbasic.exe"
tskill thinbasic
look the picture below
this is tested in windows xp/32. not sure if the same apply to windows 7 and above
to test it run the first example here: http://www.thinbasic.com/community/s...p?11886-Mirage
as it is before the later corrections. and exit it by clicking 'X' not by pressing ESC. try it 3 times so 3 instances of thinbasic.exe in the memory.
thinbasic.JPG
What, what, whaaat?
Are there any SampleScripts that do that for you? Let us know and we will have a closer look.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
It can happen when script has a Graphical User Interface (a window) and at some point there is an infinite loop.
Even if the user is able to close the window, the script is still executing the infinite loop.
It is good practice to always test, inside the infinite loop, if the main script window still exists.
In console scripts, usually closing the console window automatically close the process.
Anyway, any example showing the problem is welcome to try to find a fix.
Ciao
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Adding an explicit call to the ExitProcess(n) WinAPI (a kernel32.dll export), where n is the user-defined program exit code to be returned to the OS once the process is closed, to the program epilogue is an almost 100% foolproof method to achieve clean exit from a program of any complexity -- a multi-threaded application, a mixed GUI/CUI script, or an ordinary single-threaded GUI- or CUI-only program.
The call may be included by the developer into their interpreter's internal at-exit routine, and/or it can also be duplicated by the user in their particular script as the final statement in the application closing sequence, in which case the effect will be achieved by whatever call of the two (user or internal) will actually occur the first.
A rare case known to me that can still keep the interpreter core running is when the application spawns a sibling (not a child!) process, such as e.g. an MS Windows Help instance, via a call to ShellExecute() or ShellExecuteEx() APIs (shell32.dll exports) in the interpreter or user sources that would keep shell32.dll running despite the exit process request. In this case, it is advisable that a call to TerminateProcess() (yet another kernel32.dll export) be used instead of ExitProcess(n) in the end-user script, and/or the interpreter source code, and/or both, which is somewhat rougher but ensures the unconditional closing of all dependencies in the process to be terminated/aborted.
Last edited by mike lobanovsky; 01-08-2016 at 21:38.
Mike
(3.6GHz i5 Core Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, x64 Windows 7 Ultimate Sp1)
the sample to let thinbasic.exe stay in memory is like this:
click on 'X' and not pressing ESC keyUses "ui" DWord hwin hwin=Canvas_Window("Canvas Test",1,1,640,480) While Not GetAsyncKeyState(27) 'While Not GetAsyncKeyState(27) And IsWindow(hwin) Canvas_Color(Rgb(255,255,255),0) Canvas_SetPos(160,10) Canvas_Print("test") Canvas_Redraw Wend Canvas_Window End
in fact i feel immediately that thinbasic.exe stay in memory from the some lag in closing the window.
one day believe or not while doing too much testing and running too much scripts from other users i have about 10 thinbasic.exe until i begins to feel the system is too slow. naturaly i will press ctrl-del-alt to seel the list exe's
while in the previous forum link Eros suggested using
While Not GetAsyncKeyState(27) and IsWindow(hwin)
but in many cases the users forgot to write the correct way to exit
my solution is to make patch file such as remove.bat which have these lines
TASKLIST /FI "IMAGENAME eq thinbasic.exe"
tskill thinbasic
pause
fortunately tskill.exe will remove all instances of thinbasic , while if we use task mangaer it will end what we click on
Thanks for the example.
As you already described, to solve the problem, change While loop to something like:
In this way loop exit condition is determined by not pressing Esc and hWin is still on screen.While Not GetAsyncKeyState(27) And IsWindow(hwin) ... Wend
Without testing for the presence of the window, loop is still executing the While/Wend testing if Esc key is pressed.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
There is no one single solution to this situation.
There could be many different windows on screen, some hidden some visible. Just closing one does not mean thinBasic has to assume script is finished.
Or windows could be created from main loop only when some events occur and then close them on a timer event but main loop must still run.
So, ... not easy to find a precise situation where the thinBASIC Core engine exactly knows when it has to shut down.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks