Export (0) Print
Expand All

WebPart.RenderWorkItemTimeout method

NOTE: This API is now obsolete.

Renders HTML in a Web Part when a work item has timed out.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

<ObsoleteAttribute("Use Page.RegisterAsyncTask instead.")> _
Protected Overridable Sub RenderWorkItemTimeout ( _
	writer As HtmlTextWriter _
Dim writer As HtmlTextWriter



Type: System.Web.UI.HtmlTextWriter

An HtmlTextWriter object that defines the output to render when a work item times out.

If a Web Part does not override the RenderWorkItemTimeout method, a default system error message is rendered. The timeout setting is specified by the value of the Timeout attribute of the <WebPartWorkItem> tag that is contained within the <SharePoint> tag in the web.config file.

The following code example shows how to override the RenderWorkItemTimeout method.

Imports System
Imports System.Web.UI
Imports System.Threading
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebPartPages

Public Class WorkItemSample
    Inherits Microsoft.SharePoint.WebPartPages.WebPart
    Private log As String = ""
    Private mre As New ManualResetEvent(False)

    Public Sub New()
        AddHandler Me.PreRender, AddressOf CreateThread
    End Sub

    Private Sub CreateThread(o As Object, e As EventArgs)
        RegisterWorkItemCallback(AddressOf DoWork, Nothing)
    End Sub

    ' Sleep for 4 seconds to simulate doing work
    Private Sub DoWork(o As Object)
        log += "hello from the thread pool!<BR>"
    End Sub

    Protected Overrides Sub RenderWebPart(output As HtmlTextWriter)
    End Sub

    Protected Overrides Sub RenderWorkItemTimeout(output As HtmlTextWriter)
        output.Write("Timed out")
    End Sub
End Class

Community Additions

© 2014 Microsoft