Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Oct 22, 2017 12:37 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: WE what is the real order of code execution ???
PostPosted: Wed May 15, 2013 6:49 pm 
Offline

Joined: Tue Oct 25, 2011 4:28 am
Posts: 54
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


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Wed May 15, 2013 10:34 pm 
Offline
User avatar

Joined: Sun Dec 10, 2006 7:57 am
Posts: 124
Location: Addison, Texas
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.

_________________
Respectfully,
Eric Brown

http://www.facebook.com/ericdbrown


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Thu May 16, 2013 12:00 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Thu May 16, 2013 2:11 am 
Offline

Joined: Tue Oct 25, 2011 4:28 am
Posts: 54
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 ....


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Thu May 16, 2013 2:25 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Thu May 16, 2013 2:53 am 
Offline

Joined: Tue Oct 25, 2011 4:28 am
Posts: 54
why put these code in time is difference from code putted in webButton ???????


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Thu May 16, 2013 12:15 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Fri May 17, 2013 11:08 am 
Offline

Joined: Tue Oct 25, 2011 4:28 am
Posts: 54
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..


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Fri May 17, 2013 12:07 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Fri May 17, 2013 2:07 pm 
Offline

Joined: Tue Oct 25, 2011 4:28 am
Posts: 54
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....


Last edited by gecomail on Fri May 17, 2013 3:08 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Fri May 17, 2013 3:04 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Fri May 17, 2013 4:06 pm 
Offline

Joined: Tue Oct 25, 2011 4:28 am
Posts: 54
ok thank you tim for your patience/time.
i hove that "xojo" resolve this an other problems of RS'12


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Fri May 17, 2013 5:20 pm 
Offline
Site Admin
User avatar

Joined: Tue May 06, 2008 1:07 pm
Posts: 1464
Location: NotEvenOnTheMap, CT
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.

_________________
Thom McGrath - @tekcor
Web Framework Architect, Real Software, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Sat May 18, 2013 6:10 am 
Offline

Joined: Tue Oct 25, 2011 4:28 am
Posts: 54
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 .


Top
 Profile  
Reply with quote  
 Post subject: Re: WE what is the real order of code execution ???
PostPosted: Sat May 18, 2013 12:48 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group