« il: 10 Novembre 2013, 23:41:49 »
Vi riporto questa discussione apparsa nella M.l. ufficiale:
"
i read the wiki and sleep its prefered, but sleep stop complete
runtime, and wait i dont understand
in my program, the main Form, i change wait , and use sleep and then
some message before run process (shell executing) do not show
either in the other program, only console, works ok! why?
--
Lenz McKAY "
"
I don't completely understand your words but it's like that:
Sleep puts the program to sleep - literally. It just waits for a given time
to elapse and then resumes execution.
Wait, OTOH, keeps the interpreter active by recursively calling the event
loop. This way, events can fire, the GUI can be updated, etc..
So yes, if you use Sleep, the program will "freeze" for the given time while
with Wait you can still have your forms redraw themselves and stuff.
The thing with the console you mentioned maybe happens as follows (you
didn't really provide details): you call an external program through Shell
which is not affected by your program being asleep. If you don't catch the
output from the Shell instruction (or redirect it), it will be shown in the
IDE console, no matter if your program is Sleeping or whatever.
Regards,
Tobi "
"
> Sleep puts the program to sleep - literally. It just waits for a given time
> to elapse and then resumes execution.
all programs inherint and parent? !! ok thnks for clarification! but
some details more:
> Wait, OTOH, keeps the interpreter active by recursively calling the event
> loop. This way, events can fire, the GUI can be updated, etc..
ok but if i used waith in console? i do not note the behabior¿? that's
why i made the question as u see
> The thing with the console you mentioned maybe happens as follows (you
> didn't really provide details): you call an external program through Shell
> which is not affected by your program being asleep. If you don't catch the
> output from the Shell instruction (or redirect it), it will be shown in the
> IDE console, no matter if your program is Sleeping or whatever.
ok but i try also calling other things internally inside lopp and do
not have same behabior as when use gui forms
--
Lenz McKAY "
"
> all programs inherint and parent? !! ok thnks for clarification! but
> some details more:
I didn't say anything about a parent or inheritance, did I?
> ok but if i used waith in console? i do not note the behabior??? that's
> why i made the question as u see
What do you mean by "waith in console"? Assuming "waith" contains a typo,
how would you use Wait in console?
Do you mean: the Wait instruction in a Gambas program without GUI or do you
mean the "wait" program in a shell? Or do you mean you start an external
program in a shell from a Gambas program and then use Wait?
And... what "behaviour" do you mean after all? In the paragraph you
responded to above, I was talking about the event loop running when you use
Wait. How could that possibly *not* happen in a console program using Wait?
I'm not sure if I can really help you because I can't even guess what your
words mean - unlike others, I noticed!
> ok but i try also calling other things internally inside lopp and do
> not have same behabior as when use gui forms
It would be best if you send some code and try again to explain to me what
you think is inconsistent or confuses you.
Regards,
Tobi "
"
sorry for my very bad english Tobias, i hate that languaje, u clarify
me very well the usage.. but in one simple question, its same for a
gambas program console without gui?
in gui projects, there's a main threat running, and wait do not stop
that, but in console there's no main threath , u got it?!
Lenz McKAY "
"
Ahh. Actually, there is no "main thread" or something. Gambas is single-
threaded throughout. In GUI programs, the so-called "event loop" kicks in
automatically because you have windows open. See the docs
http://gambasdoc.org/help/cat/eventloop?v3
You can also force the event loop to run by puttingWhile True
Wait 2 ^ 30
Wend
before your Main() ends. This will call the event loop forever without being
too busy in the loop. So your program will not terminate except when you use
Quit or something.
BTW: Gambas is a nice language. You cannot make threats with it :-) Threads
are also not possible in Gambas currently. (You should look up the word
"threat" in a dictionary.) The closest thing you can have is "Task" but I've
no experience with this.
Regards,
Tobi "
« Ultima modifica: 12 Novembre 2013, 01:23:15 da vuott »
Registrato
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »