Friday, January 15, 2010

SPLongOperation - delay in redirection after the operation

Many of us may be aware of the SPLongOperation object provided by SharePoint.
Just to refresh once again, SPLongOperation is SharePoint's “Operation in Progress” spin wheel.
It could be used when time taking operations such as creating a site, running a worklow, looping through large list of items etc.. take place on the page. There are many ways to accomplish the same through AJAX. However SPLongOperation scores points for it's SharePointy look.

It renders the below on screen:

void PerformALongOperation()        
  using (SPLongOperation operation = new SPLongOperation(this.Page))
    operation.LeadingHTML = "Creating site";
    operation.TrailingHTML = "Please wait while the project site is being created for New Site";

    //Create a site, some lists in it, and then start a workflow


So far so good. It looks very straight farward to use this class.


After the operation ends, every time we encountered a delay of exactly 32 seconds before the redirection happened.

We have tried the below:

Hoewver nothing seemed to work for us.
So finally javascript redirection worked out for us:
ClientScript.RegisterClientScriptBlock(this.GetType(), "script", String.Format("", urlToRedirect));

1 comment:

  1. Hello!
    I have a similar article in my blog. Additionally I explained the reason of ThreadAbortException, which is sometimes thrown. The article is here -