Using SPLongOperation

Some SharePoint operations takes too much time to finish. After theses operations finish we need to redirect the user to another page or to the same one. SharePoint object model offers the SPLongOperation class that shows an “In progress page” that can be personalized. This page is similar to the one displayed when creating a new SharePoint site. The code snippet below shows how we can use this class and personalize this page.
   1:  using (SPLongOperation  operation = new SPLongOperation(this.Page))
   2:              {
   3:                  operation.LeadingHTML = "Operation ";
   4:                  operation.TrailingHTML = "Please wait while this operation finishes";
   5:                  operation.Begin();
   7:  // Your code here ! 
   9:                  operation.End(UrlToRedirectTo);
  11:              }

1 commentaires:

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


Enregistrer un commentaire