Real Software Forums
http://forums.realsoftware.com/

WE what is the real order of code execution ???
http://forums.realsoftware.com/viewtopic.php?f=23&t=47889
Page 1 of 2

Author:  gecomail [ Wed May 15, 2013 6:49 pm ]
Post subject:  WE what is the real order of code execution ???

I have put in webCommandButton this code :

webProgressBar1.visible=true
subProcPopulateMysqlTable
webProgressBar1.visibile=false

if i click this button the webProgressBar1 stay always invisible but subProcPopulateMySqlTable
employs 10 seconds to execute his code...
why webProgressBar not become visible and at finish of execution of subProc become invisible ???
can anyone help me ??
tnx

Author:  edb [ Wed May 15, 2013 10:34 pm ]
Post subject:  Re: WE what is the real order of code execution ???

You need to put a condition to check whether subProcPopulateMysqlTable finished before setting webProgressBar1.visible to false. The code you have now won't show the Progressbar, because it's running sequentially within a few microseconds... and the last statement is setting the visibility before it has a chance to become from the first statement.

Author:  timhare [ Thu May 16, 2013 12:00 am ]
Post subject:  Re: WE what is the real order of code execution ???

When you push a WebButton, the display state isn't pushed to the client until the entire event completes. You need to break your code up into 2 pieces.

1) Set the progressbar visible and start a short-period timer.
2) In the timer, run the sql procedure and then set the progressbar invisible.

Author:  gecomail [ Thu May 16, 2013 2:11 am ]
Post subject:  Re: WE what is the real order of code execution ???

excuse me but this is a big problem....
if i have a sub that insert 5000 records (subInsertRecords) and this sub employ 50 seconds to be executed, 100 records at second.
Then i have another sub that delete all record from the same table (subDelRecords) and this employ 5 seconds to be executed.

if i have a webButton with this code

....subInsertRecords
....subDelRecords

the result will be that the table is not clear but that the subDelRecords delete only 500 records ???
i hope that we not work in this mode ....

Author:  timhare [ Thu May 16, 2013 2:25 am ]
Post subject:  Re: WE what is the real order of code execution ???

No, you'd put both those in the same timer and they would execute in sequence. First it would insert 5000 records, and then it would delete them. Not sure where the disconnect is here.

Author:  gecomail [ Thu May 16, 2013 2:53 am ]
Post subject:  Re: WE what is the real order of code execution ???

why put these code in time is difference from code putted in webButton ???????

Author:  timhare [ Thu May 16, 2013 12:15 pm ]
Post subject:  Re: WE what is the real order of code execution ???

Coding WE is very different from coding desktop apps. You have 2 machines running 2 different programs and communicating with each other. On top of that, there is inherent latency in that communication, so it has to be optimized. The code in the webButton event runs on the server. When it is done, it sends the result to the client's Browser. If you want to see intermediate results, you have to be able to fire more than one event, so more than one result gets sent to the Browser. The Timer is merely a convenient mechanism to fire an extra event and separate the two results (progressbar visible / progressbar invisible) in time.

Author:  gecomail [ Fri May 17, 2013 11:08 am ]
Post subject:  Re: WE what is the real order of code execution ???

ok there is a example for understand this ??
i try to add a webTimer and webProgressBar_A on webPage, to webTimer control i have add a properties with name showBar as boolean
the code of webTimer.action check if webTimer.showBar is true and in this case set
webProgressBar_A.visible=true else to False; webTimer check every one second the state of showBar.
but if i put this code in the same webButton.action ..the result is that webProgressBat_A stay invisible

webTimer.showBar=true
do_function_sleep_10_seconds
webTime.showBar=false



in this case i use 2 parallel control webButton and webTimer and webTimer
i have tryed to put webTime.showbar=false inside and at the end of do_function_sleep_10_second but it the same..

Author:  timhare [ Fri May 17, 2013 12:07 pm ]
Post subject:  Re: WE what is the real order of code execution ???

Use a regular Timer, not a WebTimer. WebTimer runs on the client side in the browser, so your code suffers from the same problem - nothing is sent to the browser, including the webtimer, until your code finishes. And put do_function_sleep_10_seconds in the Timer, not in the button action.

Author:  gecomail [ Fri May 17, 2013 2:07 pm ]
Post subject:  Re: WE what is the real order of code execution ???

hi timhare, sorry but i wrote an incorrect information... in Web edition the timer is not a webTimer bu only regular timer and i have used this.
but i if i have a lot function that employ much time like fun1,fun2,fun3,fun4,fun5 etc..
i must create 1 timer for function... like fun1 in timer1, fun2 in timer2 , etc..... ??????
i have a webApp with 10/20 session at the same time...
i think that timers are danger to stability of the server ?
if function require must cpu cycle , timers adds more load to cpu or not ?
thank you .

ps.
if i put the function in timer , function that retrive 10000 record and fill a listbox i risk that the timer restart
function and fill listbox at every cycle of timer, this is a really problem....

Author:  timhare [ Fri May 17, 2013 3:04 pm ]
Post subject:  Re: WE what is the real order of code execution ???

Use a single timer and put all the code into it. The only purpose of the timer is to separate the execution of your code into 2 events.

What you have now:

WebButton.Action:
webprogressbar1.visible = true
DoSomething
DoSomethingElse
webprogressbar1.visible = false

What you should do instead:

WebButton.Action:
webprogressbar1.visible = true
timer1.mode = 1

Timer1.Action:
DoSomething
DoSomethingElse
webprogressbar1.visible = false

Note that this isn't the only way to solve the problem, and it may not even be the best, but it is a convenient, quick and dirty solution that requires little code modification.

Author:  gecomail [ Fri May 17, 2013 4:06 pm ]
Post subject:  Re: WE what is the real order of code execution ???

ok thank you tim for your patience/time.
i hove that "xojo" resolve this an other problems of RS'12

Author:  Thom McGrath [ Fri May 17, 2013 5:20 pm ]
Post subject:  Re: WE what is the real order of code execution ???

gecomail wrote:
ok thank you tim for your patience/time.
i hove that "xojo" resolve this an other problems of RS'12

It will not. This is not a problem, this is by design. Because of how HTTP works, we cannot send more than one set of instructions to the browser per event. This is not our restriction, it is a restriction of HTTP. If we sent the instruction as soon as you made the ProgressBar invisible, you wouldn't get any of the later instructions. That's why we send all the instructions at the end of the event. There's no other way.

Author:  gecomail [ Sat May 18, 2013 6:10 am ]
Post subject:  Re: WE what is the real order of code execution ???

to timhare...
i check the help of RS and i see that the timer for WE is only webTime (...client side).
how can you use a normal timer in webApplication ????????????????????????
on my control list of my rsWE i can view/insert only webTimer .

Author:  timhare [ Sat May 18, 2013 12:48 pm ]
Post subject:  Re: WE what is the real order of code execution ???

If the IDE won't let you create one on the window, you can create it in code. Add a property to the window As Timer and use AddHandler to tie the timer to a method on the window.

Page 1 of 2 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/