del método WebPart.RenderWorkItemTimeout

NOTA: esta API está ahora obsoleta.

Representa el HTML en un elemento Web cuando un elemento de trabajo ha agotado el tiempo.

Espacio de nombres:  Microsoft.SharePoint.WebPartPages
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

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

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

Parámetros

  • writer
    Tipo: System.Web.UI.HtmlTextWriter

    Un objeto HtmlTextWriter que define el resultado para representar cuando se agota el tiempo de espera de un elemento de trabajo.

Comentarios

Si un elemento Web no reemplaza el método RenderWorkItemTimeout , se representa un mensaje de error del sistema predeterminado. El valor de tiempo de espera es especificado por el valor del atributo de tiempo de espera de la etiqueta < WebPartWorkItem > que se encuentra dentro de la etiqueta < SharePoint > en el archivo web.config.

Ejemplos

En el ejemplo de código siguiente se muestra cómo reemplazar el método RenderWorkItemTimeout .

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

Vea también

Referencia

clase WebPart

Miembros WebPart

Espacio de nombres Microsoft.SharePoint.WebPartPages