WebPart.RenderWorkItemTimeout method
SharePoint 2013
NOTE: This API is now obsolete.
Renders HTML in a Web Part when a work item has timed out.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
[ObsoleteAttribute("Use Page.RegisterAsyncTask instead.")] protected virtual void RenderWorkItemTimeout( HtmlTextWriter writer )
Parameters
- writer
- Type: System.Web.UI.HtmlTextWriter
An HtmlTextWriter object that defines the output to render when a work item times out.
The following code example shows how to override the RenderWorkItemTimeout method.
using System; using System.Web.UI; using System.Threading; using System.Xml.Serialization; using Microsoft.SharePoint; using Microsoft.SharePoint.WebPartPages; namespace ExampleWebParts { public class WorkItemSample : Microsoft.SharePoint.WebPartPages.WebPart { string log=""; ManualResetEvent mre = new ManualResetEvent(false); public WorkItemSample() { this.PreRender+=new EventHandler(CreateThread); } private void CreateThread(object o, EventArgs e) { RegisterWorkItemCallback(new WaitCallback(DoWork), null); } // Sleep for 4 seconds to simulate doing work private void DoWork(object o) { Thread.Sleep(4000); log+="hello from the thread pool!<BR>"; mre.Set(); } protected override void RenderWebPart(HtmlTextWriter output) { output.Write(log); } protected override void RenderWorkItemTimeout(HtmlTextWriter output) { output.Write ("Timed out"); } } }