|
Rank: Member Groups: Member
Joined: 12/2/2009 Posts: 23
|
Hi,
I am trying to do a deferred load of my page. I put the contents into a CallBackPanel. The only way I could think to do the callback on startup was to create a checkbox that was set as a trigger for the panel and I used a startup JavaScript to hide and click the checkbox. This invokes the callback and it works mostly.
First, is there a better way to do this?
Second and more important, the point of the deferred load was to allow the user to use our menus to navigate away from the page without waiting for the callback to complete (it does a bunch of SQL). My test system is quick, so I added a System.Threading.Thread.Sleep(5000) on Execute to slow it down. When I hit a menu item, the callback completes and then the menu executes.
Am I shooting myself in the foot by using the Sleep? Will this approach work?
If not, suggestions for other choices would be appreciated.
Thanks...Ron
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You can call eo_Callback to trigger a callback directly without going through a trigger control.
I am not sure whether I understand your purpose of Sleep correctly though. Even without the sleep, user still can click and navigate away using the menu right? So why how much time Execute takes to run matter?
Thanks!
|
|
Rank: Member Groups: Member
Joined: 12/2/2009 Posts: 23
|
1) Where is eo_Callback defined? It is not a function in the page source... 2) Sleep is not relavant, I replaced it with many calls to my SQL code and the result is the same. The process seems to be single threaded. While in the callback, I can click on the page, but it does not respond until after the callback has been completed. The idea behind the callback was to allow me to navigate away from the page without waiting for the SQL to complete.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
ron wrote:1) Where is eo_Callback defined? It is not a function in the page source... The function is defined in our js files and is documented here: http://doc.essentialobjects.com/library/1/jsdoc.public.global.eo_callback.aspxThere are a lot of functions/objects that are defined in our .js files and you won't see them the page source. You can take a look of our client side JavaScript API to see what's there. ron wrote:2) Sleep is not relavant, I replaced it with many calls to my SQL code and the result is the same. The process seems to be single threaded. While in the callback, I can click on the page, but it does not respond until after the callback has been completed. The idea behind the callback was to allow me to navigate away from the page without waiting for the SQL to complete. That is normal. ASP.NET manages all pages life time and it makes sure that all requests that comes from the same session are executed "singled threaded" (ASP.NET still serves multiple sessions from multiple threads). This is necessary so that your code never needs to worry about multiple thread synchronization issues while accessing session variables. If you want to avoid this, you will need to do your SQL work from a different thread other than the page thread or looking into asynchronous page. Asynchronous page needs some work on the page level and it does not work well with Callbacks. So putting the code in a worker thread might be the best option for you ---- but actually you don’t need a CallbackPanel to trigger that. Just fire it off in your Page_Load and you are done. Hope this helps. Thanks
|
|
Rank: Member Groups: Member
Joined: 12/2/2009 Posts: 23
|
1) I understand - I'll look it up. 2) a) it was acting sigle threaded so this makes sense b) I thought this would work with AJAX code in the page off a timer, but I was hoping using your control would be easier. c) I am not understanding how a worker thread on the server helps. How do I return control to the user and show the results of the worker thread when they are available?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
ron wrote:b) I thought this would work with AJAX code in the page off a timer, but I was hoping using your control would be easier. It doesn't matter much, neither will work for you. As soon as it is still you (the same session), you are locked down to one thread and queued up by ASP.NET. It doesn't really care about whether AJAX or what AJAX you use. ron wrote:c) I am not understanding how a worker thread on the server helps. How do I return control to the user and show the results of the worker thread when they are available? You don't. You ask user to refresh the page to check later or code to automatically refresh it (for example, using an AJAX timer). ASP.NET also has asynchronous page that is more or less for this scenario so you may want to take a look of that. In any case all of these are actually outside of the scope of our support, so if you still have any questions, you will want to seek help from other resource. Thanks!
|
|
Rank: Member Groups: Member
Joined: 12/2/2009 Posts: 23
|
Thanks... I realized on my prior post that we had moved past your support area, but I appreciate your helping as much as you did.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You are very welcome and we appreciate your understanding. Glad that we helped!
|
|
Rank: Member Groups: Member
Joined: 12/2/2009 Posts: 23
|
I succeeded in having a deferred load by using a series of callbacks; each doing a single SQL call. This allowed me to use your standard CallbackPanel. I created the series using the ClientScriptAfterUpdate to invoke the next callback.
Now I only need to figure out why my whole page is offset to the right by an inch... my task for tomorrow. LOL
Thanks again...Ron
|
|