473,394 Members | 1,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Preventing Simultaneous Functions

kid
I need help with a page i'm coding which has several functions to
dynamically change the display. Everything works fine but the problem
is that I need to have the final function wait for all others to
finish before it resets certain onscreen buttons and then returns.I'm
having trouble implementing this efficiently and would greatly
appreciate any help/comments.
Jul 23 '05 #1
2 1036
kid wrote:
I need help with a page i'm coding which has several functions to
dynamically change the display. Everything works fine but the problem
is that I need to have the final function wait for all others to
finish before it resets certain onscreen buttons and then returns.I'm
having trouble implementing this efficiently and would greatly
appreciate any help/comments.


Post *relevant snippets* of your code or the URI
of a test case and we will see what can be done.
PointedEars
Jul 23 '05 #2
kid wrote:
I need help with a page i'm coding which has several functions to
dynamically change the display. Everything works fine but the problem
is that I need to have the final function wait for all others to
finish before it resets certain onscreen buttons and then returns.I'm
having trouble implementing this efficiently and would greatly
appreciate any help/comments.


Yeah... what Thomas said... except, here is a basic outline of something
you might want to try... untested, but it should help out. If you show
more, we can help more.

First of all, I am assuming you must be using something like setTimeout
on all of your functions to execute. This assumption is based off the
fact that Javascript executes serially in all browsers I know about.
This means that you should know when a script is done, unless you are
setting events (via setTimeout or setInterval).

Ok, making that assumption, think about this:

/////////////////////////////////////////////////////////////////
var func1_done = false;
var func2_done = false;
var func3_done = false;

function func1() {
//... code
func1_done = true;
}

function func2() {
//... do someting
func2_done = true;
}

function func3() {
//... do something
func3_done = true;
}

function checkForDone() {
if( func1_done && func2_done && func3_done )
{
// Do what you need to do... all three are done
}
else
setTimeout("checkForDone()", 500); // check again in 1/2 sec
}
/////////////////////////////////////////////////////////////////

Then, you can run checkForDone, when you want to execute your code. It
will only execute if 1, 2 and 3 are done. If not, it will try again in
half of a second (change this to whatever you think is necessary)

Also, for good programming practices, use an array for the funcN_done
flags, if you have more than three functions to worry about.

Brian
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Claudio Grondi | last post by:
I would like to save time copying the same file (>6 GByte) to various different target storage media connected to the system via USB. Is there a (Python or other) tool able to help me to do...
5
by: Fred | last post by:
Hi out there, I have problems finding a way to warn a user that another user intends soon to update the same specific row. Let me explain. User 1 get to a JSP "update customer record" page....
1
by: slugger | last post by:
Hope this is not OT: I am running into some strange things whenever my ASP pages send out simultaneous requests to another ASP page which in turn gains access to a MySQL database using a DSNless...
6
by: Jimnbigd | last post by:
I want to write a game, and sounds will really add to it. Note that I would always make the sounds optional. I hate it when I go to a URL and unexpectedly get sounds or music. I have played...
1
by: Semaj | last post by:
Environment: DB2 8.1.4; Windows 2000 We are evaluating the feasibility of upgrading our production DB from 7.2 to 8.1. During this process we've encountered an error when starting our...
12
by: Dan V. | last post by:
Since an ASP.NET/ADO.NET website is run on the server by a single "asp_net worker process", therefore doesn't that mean that even 50 simultaneous human users of the website would appear to the...
5
by: www.douglassdavis.com | last post by:
I have an idea for preventing sql injection attacks, however it would have to be implemented by the database vendor. Let me know if I am on the right track, this totally off base, or already...
10
by: David Hirschfield | last post by:
Here's a strange concept that I don't really know how to implement, but I suspect can be implemented via descriptors or metaclasses somehow: I want a class that, when instantiated, only defines...
4
by: raylopez99 | last post by:
Compound question: first, and this is not easy, if there's a way to detect multiple simultaneous key presses in C# let me know (in the below code, keys c and d being pressed simultaneously or...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.