3
votes

I have used the Long Running Operation capability within the Publishing Infrastructure within MOSS (SharePoint) in the past, and am curious if anyone knows if this is a supported technique for having custom long running operations within SharePoint.

When using this technique, you inherit from Microsoft.SharePoint.Publishing.Internal.LongRunningOperationJob which seems to indicate that it is not supported for custom use, but I seem to recall (maybe I dreamt?) that long running processes was a marketed feature of MOSS.

Any ideas?

4

4 Answers

2
votes

SharePoint Timer Jobs are described in MSDN Journal April edition http://msdn.microsoft.com/en-us/magazine/dd569748.aspx

1
votes

Good question Kirk! I have recently also experienced the need to implement long running jobs in SharePoint. But the LongRunningOperationJob was not an option as it also needed to work with a plain WSS 3.0 deployment. I simply ended up spawning a new thread from the Web request and redirecting to an ASPX page with an AJAX enabled progress bar updating itself every other second. It works perfectly well and can run as long as needed. Only downside is that an IISRESET will kill it for good. Another possibility could be to implement long running jobs using a custom SharePoint Timer Job.

1
votes

SPLongOperation is a very simple way to do a long running operation. Much simpler than the Publishing.LongRunningOperationJob and uses the same infrastructure.

1
votes

Ever woundered how microsoft create the nice longrunning process windows works in SharePoint 2007?

SPLongOperation is the class to use. It has 2 important methods

Begin and End;

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 :-)

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)
  {
     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");
  }
 }
}