Javascript execution sequence problem

S

Stephan Parrot

Hello people!

I have a really weird problem here...
Let's say i have 4 lines of codes in a function like this one:


SomeSVGDialog.Show(); //this is an SVG dialog box that shows to give
some feedback
FunctionCall1(); //these functions calls webforms via XMLHTTP and
erform stuff
FunctionCall2();
FunctionCall3();
SomeSVGDialog.Hide();//thide the feedback window

OK... The way I see it, the normal sequence of events would be, the
feedback form is displayed, then, FunctionCall1, FunctionCall2 and
FunctionCall3 are executed and then the feedback window would hide,
right?

WRONG!!!
Right now, the feedback window isnt even displayed...
all operations are performed but i dont see the feedback form showing
up...
I have found a quick fix to that but its not really pretty...
I am doing this:

SomeSVGDialog.Show();

var DisplayTimer = setTimeout("FunctionCall1();FunctionCall2();FunctionCall3();SomeSVGDialog.Hide();",
500);

this work perfectly!!

Someone told me it may be because i am running the client javascript
code on a machine with multiple processors... Which is correct but i
didnt have the opportunity to test it on a single processor machine
yet...
In any case, id like to know if someone knows why this happens and how
to fix it if possible because i cannot assume users will all have
single CPU machines...

Thanks in advance!

Stephan Parrot
 
R

Ron

Stephan Parrot said:
Hello people!

I have a really weird problem here...
Let's say i have 4 lines of codes in a function like this one:


SomeSVGDialog.Show(); //this is an SVG dialog box that shows to give
some feedback
FunctionCall1(); //these functions calls webforms via XMLHTTP and
erform stuff
FunctionCall2();
FunctionCall3();
SomeSVGDialog.Hide();//thide the feedback window

OK... The way I see it, the normal sequence of events would be, the
feedback form is displayed, then, FunctionCall1, FunctionCall2 and
FunctionCall3 are executed and then the feedback window would hide,
right?

WRONG!!!
Right now, the feedback window isnt even displayed...
all operations are performed but i dont see the feedback form showing
up...
I have found a quick fix to that but its not really pretty...
I am doing this:

SomeSVGDialog.Show();

var DisplayTimer = setTimeout("FunctionCall1();FunctionCall2();FunctionCall3();SomeSVGDialog.Hi
de();",
500);

this work perfectly!!

Someone told me it may be because i am running the client javascript
code on a machine with multiple processors... Which is correct but i
didnt have the opportunity to test it on a single processor machine
yet...
In any case, id like to know if someone knows why this happens and how
to fix it if possible because i cannot assume users will all have
single CPU machines...

Thanks in advance!

Stephan Parrot

Stephen,

What happens if you add an Alert() to stall the program flow after the
window open routine?

I'm wondering if the time taken to launch the new window is more than the
time taken to execute the other functions, so the window closes before you
get to see it.
Your workaround with a timer tends to support this.
how about just commenting out the close window ? What happens then.

HTH

Ron
 
S

Stephan Parrot

Hi Ron, thanks for the reply!

Ok... I tried to remove the .Hide call and the window is displayed after
the 3 functions call after it...

I've put alerts too... Before and after... went ok... sequentially...
So... Either its the svg viwer pluggin that takes too much time to
generate the svg from the javascript OR it's because the viewer wait for
the function to exit before drawing it on screen... You know?
The function must be interpreted entirely before letting the viewer do
his job...

In any ways, i'm stuck with the timer solution right now and i'm not
happy with it...

I'll do some other tests and try to speak with guys from the svg
community if they know about that problem...

If you have some explanation for me or anything that could be helpfull,
please let me know!

If i find the solution or if someone directs me to one, ill let the
forum know.

Thanks a lot!

Stephan Parrot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top