Microsoft.SharePoint


SPLongOperation Class (Microsoft.SharePoint)
Sets the web page image to the image used by the server to indicate a lengthy operation (typically, a rotating gear image with associated text).

Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
Public NotInheritable Class SPLongOperation
    Implements IDisposable
Visual Basic (Usage)
Dim instance As SPLongOperation
C#
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
public sealed class SPLongOperation : IDisposable
Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.SPLongOperation
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Tags : sharepoint wss


Community Content

Olek Naleczynski
How To: Create long running operations

All your code that runs for a long time is placed between begin and end.

Below is a sample class.

It is almost to simple and just works

SPLongOperation is IDisposable, and should be called inside using statement, or manually disposed.


using System;
using System.Web;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
namespace CreateLongOperation
{
public class LongRun : System.Web.UI.Page
{
protected Button buttonOk;

protected void Page_Load(object sender, EventArgs e)
{
buttonOk.Click += new EventHandler(buttonOk_Click);
}

void buttonOk_Click(object sender, EventArgs e)
{
using (SPLongOperation operation = new SPLongOperation(this.Page))

{

operation.Begin();

// do long operation code here...
System.Threading.Thread.Sleep(6000);

operation.End(http://sps/_layouts/Mynewpage.aspx);

}
}
}
}

Check my blog for updates to this http://lemming.biz


Page view tracker