|
If you have ever worked with MOSS or SharePoint 2010 you remember this page:
It appears when you create new sites or run any other long-running operations. Now, did you know that it’s very easy to have this page displayed during your own long-running operations? Not only that, it will redirect back to your code when it’s done with the execution. Let’s say I have a UserControlWebpart in my SharePoint solution, and in my OnLoad method I call a couple of long-running operations and want the “Processing” page to show up. When completed, I want to come back to my page where the UserControlWebpart is. Here is all I need to wrap my custom long-running code with: string comeBackUrl = this.ViewState["__REFERER__"].ToString(); using (SPLongOperation operation = new SPLongOperation(this.Page)) { operation.Begin(); //….. your code here …. operation.End(comeBackUrl, Microsoft.SharePoint.Utilities.SPRedirectFlags.DoNotEncodeUrl, HttpContext.Current, null); } That`s all that you need to do; SharePoint takes care of the rest.
|