Handling Long Operations

SharePoint Short #13

Got some code that may take a while to complete? Good idea to let the user know they may have to wait a while, so put your code within the SPLongOperation block, as shown below, and it’s problem solved.

using(SPLongOperation longOperation = new SPLongOperation(Page))
{
    longOperation.LeadingHTML = "Please wait while the operation completes...";
    longOperation.Begin();
 
    try
    {
        // Operations that may take a while to complete...
    }
    finally
    {
        longOperation.End("somepage.aspx", SPRedirectFlags.Static | SPRedirectFlags.RelativeToLayoutsPage | SPRedirectFlags.Trusted, System.Web.HttpContext.Current, string.Empty);
    }
}
This entry was posted in SharePoint Shorts and tagged . Bookmark the permalink.
0 0 votes
Article Rating
Subscribe
Notify of
guest

Solve the maths problem shown below before posting: *

0 Comments
Inline Feedbacks
View all comments