Hi,
The initial load of my application’s main screen involves a number of server requests being sent - one to get company details, one to get user details, one to get the details of today’s bookings, etc. I presume that these are sent sequentially over the same connection, but are then handled concurrently by multiple Tomcat threads, with the result that I can’t predict the order in which the JS callback functions will be invoked (I’m not getting horrendous client-side sync problems, which makes me think that JS itself is not multi-threaded and we are only ever running one function at a given instant in time - would this be correct?)
Anyway, I am currently solving this problem by causing my client-side callbacks to set a global var indicating that they have run - so I have a companyCallbackOK, a userCallbackOK, and so forth. I also ensure that each callback checks the global vars associated with any callbacks that must finish earlier, and if any of those vars are not yet set, it schedules itself to run again in 50ms, and ends.
This works fine, but it’s hardly a robust solution - it depends on me correctly coding the exclusions manually each time I add a new server call, and also relies on me setting the global vars back to false each time I re-invoke a server call. I daresay I could dig out my old Computer Science textbooks and code up a mutual exclusion class to do the job better, but it strikes me that this must be a fairly common problem for any app using a multi-threaded server, so I thought I’d check first to see if you already have a way of synchronising server responses built in to SmartClient.
Thanks,
Wayne