What is best practice to implement a long running operation in a web part.

From what I have read so far it is recommended to use PageAsyncTask or a timer which ticks once to initiate data loading.

Now I have tested PageAsyncTask and the timeout is reached after ~7 seconds in my dev environment which is not enough time for my operation. The timer way causes another problem because it fires a postback which causes an issue in combination with the project summary web part. You you can find the problem description here: New SP Timeline web part not ajax friendly!

I need to make some calls in code behind so the only way around this I can think of at the moment would be to create a web service which is then called by JS inside the web part.

  • what exactly are you trying todo? by that i mean what is the webpart trying todo? 7 seconds in computing time is a long time!
    – Ali Jafer
    Dec 13, 2013 at 9:30
  • E.g. I need to create an employee diagram. For this I need to iterate all user profiles and load additional information from the active directory. For this 7 seconds is unfortunately not enough. Even though I'm using caching which means this issue only occurs for first loading every day.
    – André
    Dec 13, 2013 at 9:33

1 Answer 1


you have several options to this issue! the problem is as you said is the looping that causes bad timing issues!

you have multithreading:


you can do it through a timer job:


both of the above still hit the issue of it taking ages to update! So this would lead me to your information! how many times is the info going to be updated? once a day/week/month/year? how is it displayed?

from all the above, i would encorporate the usage of SQL server to hold the information and timer job to update the table that will hold the data! You then have cashing to cashe the data on first load to ease off on the SQL server calls!

Why SQL server? if your updating the information once a day/week/month/year, it could be done through a timerjob in the middle of the night so it doesnt effect anyone, the data is stored on the SQL server and saved into a table ready for the first call.. You use a stored procedure to retive the information to display to the ui. Most of the heavy loading is done out of hours and the light info gathering is done on first loading of the page and stored in cashe! SQL sever would be the best option in your case and i would say for best practice!

You should see it load within a matter of milliseconds!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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