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();
   6:                 
   7:  // Your code here ! 
   8:                  
   9:                  operation.End(UrlToRedirectTo);
  10:   
  11:              }


1 commentaires:

Hello!
I have a similar article in my blog. Additionally I explained the reason of ThreadAbortException, which is sometimes thrown. The article is here - http://dotnetfollower.com/wordpress/2011/08/sharepoint-how-to-use-splongoperation/
Thanks!

Reply

Enregistrer un commentaire