Click to Rate and Give Feedback
MSDN
MSDN Library
Office Development
Visual How Tos
 Coding a Long-Running Operation Pag...
Community Content
In this section
Statistics Annotations (0)
Coding a Long-Running Operation Page in SharePoint Server 2007 or Windows SharePoint Services 3.0

Summary: Learn how to write code to mimic the default long-running operations page (the "spinning wheel") in Microsoft Office SharePoint Server 2007 or Windows SharePoint Services 3.0.

Office Visual How To

Applies to: Microsoft Office SharePoint Server 2007, Windows SharePoint Services 3.0

David Mann, Mann Software

August 2009

Overview

The Long-Running Operation page is familiar to anyone who uses Microsoft Office SharePoint Server 2007. It is called many things (including the spinning gears page and the spinning wheel) but it all comes down to a consistent UI for times when SharePoint Server needs to be doing a lot of work but the user is sitting and waiting. The ability to mimic this default functionality can make your application fit in with the rest of SharePoint Server.

Code It

The code for a long-running operation is simple: whatever code you place between your calls to Begin and End constitutes the long-running operation.

C#
using (SPLongOperation operation = new SPLongOperation(this.Page))
{
  operation.LeadingHTML = "Please wait while the operation runs";
  operation.TrailingHTML = "";
  operation.Begin();
  if (DoOperation())
    ProcessResults = "Operation Completed Successfully";
  else
    ProcessResults = "An error occurred and was handled.";
  operation.End("LongRunnngOperation/Results.aspx", 
        SPRedirectFlags.UseSource |
        SPRedirectFlags.RelativeToLayoutsPage, 
        this.Context, "result=" + 
        Server.UrlEncode(ProcessResults));
}
Read It

The heart of the long-running operation happens in between the .Begin statement and the .End statement. While any code you place in between these two statements is running, the user sees the long-running operation page. When your work is complete, the .End statement is responsible for redirecting the user to whichever page you need them to view next—for example, a results page, settings.aspx, or the next page in a wizard.

See It

Coding a Long-Running Operation Page

Watch the Video

Video Length: 00:07:56

File Size: 11.8 MB WMV

Explore It
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker