Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In our home page we have multiple web parts that get the data from different webservices or from a recursive search in some lists in the site collection.

We detected that all this calls were too slow, so we decided to load the data once the page is enabled. To do this, we added a update panel in each web part and a timer like this:

<asp:UpdatePanel runat="server" id="UpdatePanel1">
<ContentTemplate>
<asp:Timer runat="server" id="Timer1" Interval="1" OnTick="Load_Data"></asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>

In Load_Data function Timer1 is removed, the data is load and it is rendered inside the updatepanel.

This works perfectly, except that all webparts are load sequentially. That means that the second webpart is not loaded until the first is loaded and the same for all others. I want to load all web parts at a time and when one is ready, render this one.

How can I accomplish this?

share|improve this question
    
Do you use async methods to load data in Load_Data methods? –  Alexander Jan 9 '12 at 13:23
    
No, I don't use them yet. It is one of to-do things we have planned. But will it work with update panels? I tried to call Load_Data methods within a thread and it resulted that my webparts didn't get the postback result properly. Besides, this methods are not available in site collection's recursive search. –  Bargant Jan 10 '12 at 7:36

3 Answers 3

up vote 1 down vote accepted

I'm not really a developer, but I believe the core of the problem is that ASP.NET processes each page request using a single thread (even where there are multiple Web parts). An UpdatePanel is a really a page-postback and AFAIK it can only post one event at a time.

As such, you will most likely need to create and register asynchronous tasks (i.e. using instances of the PageAsyncTask class and the RegisterAsyncTask method) in order to utilise additional threads for expensive calls over the network.

There is a section on this in the book "Inside Microsoft SharePoint 2010" which is definitely worth a read.

share|improve this answer
    
So, either I have asyncronous loads while the page is rendered and it is not available until all them end, or I have deleayed loads but sequentially. Am I wrong? –  Bargant Jan 10 '12 at 8:35
    
If you use asynchronous processing, each Web Part would be able to call across the network on a new (non blocking) thread allowing calls to be made in parallel. Total page response time would = the Web part that takes the longest as opposed to the sum of all network calls. –  Benjamin J Athawes Jan 10 '12 at 8:46
    
Ok, thank you. I would prefer a mix of the two solutions, but now at least I know I can't (until somebody tells me the opposite). The problem is that we have some calls that can last 10 seconds to retrieve the data, so maybe it is not a good solution having the page not available all this time. I also have detected that having the delayed load, webparts are loaded in order. That means that the first in page will be the first to load. It could be interesting in some scenarios (tabs perhaps?). –  Bargant Jan 10 '12 at 9:53
    
You could also try adding an interim placeholder to each Web part (e.g. a "Loading" gif) so that the rest of the page loads prior to making your expensive calls. There is an example here: ahmedmadany.wordpress.com/2011/05/18/… –  Benjamin J Athawes Jan 10 '12 at 11:23
    
That's just how it is now :) , but I haven't included it in the codesample because I thought it wasn't relevant. The user experience is quite good, except for the sequential load effect... Maybe the best solution is having the less expensive webparts with asyncron load and the most expensive with delayed load and trying not to have many of the expensives ones in a Page. –  Bargant Jan 10 '12 at 13:50

I've been experiencing the same problem. I have a SharePoint dashboard where all my custom webparts reside (currently 9 webparts). All webparts retrieve their data from web services and while using AJAX with the Timer works well in terms of initial page load, it can take up to 30 seconds for the last webpart in the sequence to get its data which doesn't look very professional at all.

I tried using PageAsyncTask, but as you've found out, this results in the page load time being as slow as the slowest webpart, which in my opinion is a worse user experience than sequentially loading the webparts using a Timer.

What I'm trying now is to continue to use the Timer control, but in the OnTick() method try to call my web services asynchronously. The other option is to use JavaScript to get the client to call the web services. This takes some load off the server which could also be an advantage.

share|improve this answer
    
I think that trying to call the PageAsyncTask at OnTick() method will still load the web parts sequentially since a tick will not jump until the previous OnTick() method has ended. Correct me is I'm wrong, please. –  Bargant Jan 26 '12 at 10:04

Have you tried to set the timer interval to something higher than 1 ms? The default is 60.000 (60 s). Or remove the timer completely. As I understand it you only need the timer if you want to update the contents of the web parts periodically. You could also check-out the asynchronous web part settings (under 'edit web part') since you are using SharePoint 2010.

share|improve this answer
    
This webparts are custom and they not have asynchronous settings. The timer is needed in order to start a postback once the page is loaded, and after its first tick it is removed. It is not used to update the contents periodically. –  Bargant Jan 10 '12 at 8:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.