Freigeben über


WebPart.RenderWorkItemTimeout-Methode

HINWEIS: Diese API ist veraltet.

Rendert HTML in einem Webpart aus, wenn eine Arbeitsaufgabe ein Timeout aufgetreten ist.

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

Syntax

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

Me.RenderWorkItemTimeout(writer)
[ObsoleteAttribute("Use Page.RegisterAsyncTask instead.")]
protected virtual void RenderWorkItemTimeout(
    HtmlTextWriter writer
)

Parameter

  • writer
    Typ: System.Web.UI.HtmlTextWriter

    Ein HtmlTextWriter -Objekt, das die Ausgabe gerendert werden, wenn eine Arbeitsaufgabe Zeitüberschreitung definiert.

Hinweise

Wenn ein Webpart nicht die RenderWorkItemTimeout -Methode außer Kraft, wird eine Standardfehlermeldung System gerendert. Die Timeout-Einstellung wird durch den Wert des Attributs Timeout des Tags < WebPartWorkItem > angegeben, der innerhalb des < SharePoint >-Tags in der Datei web.config enthalten ist.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie die RenderWorkItemTimeout -Methode außer Kraft gesetzt.

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)
        Thread.Sleep(4000)
        log += "hello from the thread pool!<BR>"
        mre.Set()
    End Sub

    Protected Overrides Sub RenderWebPart(output As HtmlTextWriter)
        output.Write(log)
    End Sub

    Protected Overrides Sub RenderWorkItemTimeout(output As HtmlTextWriter)
        output.Write("Timed out")
    End Sub
End Class
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");
        }
    }
}

Siehe auch

Referenz

WebPart Klasse

WebPart-Member

Microsoft.SharePoint.WebPartPages-Namespace