WebThreadInformation Sınıf

Tanım

ASP.NET bir işlemdeki iş parçacığının durumu hakkında bilgi sağlar.

public ref class WebThreadInformation sealed
public sealed class WebThreadInformation
type WebThreadInformation = class
Public NotInheritable Class WebThreadInformation
Devralma
WebThreadInformation

Örnekler

Aşağıdaki kod örneğinde iki bölüm vardır. birincisi, ASP.NET WebThreadInformation türünü kullanan özel bir olay kullanmasını sağlayan bir yapılandırma dosyasının alıntısıdır. İkincisi, türünü kullanan WebThreadInformation özel olayın nasıl uygulandığını gösterir.

Özel olayınızın doğru zamanda, yani değiştirdiği eşdeğer sistem durumu olayının tetiklendiğinde tetiklendiğinden emin olun.

<healthMonitoring
    heartBeatInterval="0" enabled="true">

  <profiles>
    <add name="Custom"
      minInstances="1"
      maxLimit="Infinite"
      minInterval="00:00:00" />
  </profiles>

  <eventMappings>

    <add
      name="SampleWebThreadInformation"
type="SamplesAspNet.SampleWebThreadInformation,webthreadinformation, Version=1.0.1782.29648, Culture=neutral, PublicKeyToken=b3283a2de7dd3f27, processorArchitecture=MSIL" />

  </eventMappings>

  <rules>

    <add name="Custom Web Thread Info Event"
      eventName="SampleWebThreadInformation"
      provider="EventLogProvider"
      profile="Custom" />

  </rules>

</healthMonitoring>

using System;
using System.Text;
using System.Web;
using System.Web.Management;

namespace SamplesAspNet
{
    // Implements a custom WebErrorstEvent that uses the 
    // WebThreadInformation. 
    public class SampleWebThreadInformation :
        WebErrorEvent
    {
        private StringBuilder eventInfo;

        // Instantiate events identified 
        // only by their event code.
        public SampleWebThreadInformation(
            string msg, object eventSource,
            int eventCode, Exception e)
            :
            base(msg, eventSource, eventCode, e)
        {
            // Perform custom initialization.
            eventInfo = new StringBuilder();
            eventInfo.Append(string.Format(
            "Event created at: {0}",
            EventTime.ToString()));
        }

        // Raises the event.
        public override void Raise()
        {
            // Perform custom processing. 
            eventInfo.Append(string.Format(
                "Event raised at: {0}",
               EventTime.ToString()));
            // Raise the event.
            base.Raise();
        }

        // Get the impersonation mode.
        public string GetThreadImpersonation()
        {
            return (string.Format(
                "Is impersonating: {0}",
                ThreadInformation.IsImpersonating.ToString()));
        }

        // Get the stack trace.
        public string GetThreadStackTrace()
        {
            return (string.Format(
                "Stack trace: {0}",
                ThreadInformation.StackTrace));
        }

        // Get the account name.
        public string GetThreadAccountName()
        {
            return (string.Format(
                "Request user host address: {0}",
                ThreadInformation.ThreadAccountName));
        }

        // Get the task Id.
        public string GetThreadId()
        {
            // Get the request principal.
            return (string.Format(
                "Thread Id: {0}",
                ThreadInformation.ThreadID.ToString()));
        }


        // Formats Web request event information.
        public override void FormatCustomEventDetails(
         WebEventFormatter formatter)
        {

            // Add custom data.

            formatter.AppendLine("");
            formatter.AppendLine(
                "Custom Thread Information:");

            formatter.IndentationLevel += 1;

            // Display the thread information obtained 
            formatter.AppendLine(GetThreadImpersonation());
            formatter.AppendLine(GetThreadStackTrace());
            formatter.AppendLine(GetThreadAccountName());
            formatter.AppendLine(GetThreadId());
            formatter.IndentationLevel -= 1;

            formatter.AppendLine(eventInfo.ToString());
        }

    }
}
Imports System.Text
Imports System.Web
Imports System.Web.Management



' Implements a custom WebErrorstEvent that uses the 
' WebThreadInformation. 

Public Class SampleWebThreadInformation
   Inherits WebErrorEvent
   Private eventInfo As StringBuilder
   
   
   ' Instantiate events identified 
   ' only by their event code.
    Public Sub New(ByVal msg As String, _
    ByVal eventSource As Object, _
    ByVal eventCode As Integer, ByVal e As Exception)
        MyBase.New(msg, eventSource, eventCode, e)
        ' Perform custom initialization.
        eventInfo = New StringBuilder()
        eventInfo.Append(String.Format("Event created at: {0}", EventTime.ToString()))
    End Sub
   
   
   
   ' Raises the event.
   Public Overrides Sub Raise()
      ' Perform custom processing. 
        eventInfo.Append(String.Format( _
        "Event raised at: {0}", EventTime.ToString()))
      ' Raise the event.
      MyBase.Raise()
   End Sub
   
   ' Get the impersonation mode.
   Public Function GetThreadImpersonation() As String
        Return String.Format( _
        "Is impersonating: {0}", _
        ThreadInformation.IsImpersonating.ToString())
   End Function 'GetThreadImpersonation
   
   ' Get the stack trace.
   Public Function GetThreadStackTrace() As String
        Return String.Format( _
        "Stack trace: {0}", _
        ThreadInformation.StackTrace)
   End Function 'GetThreadStackTrace
   
   ' Get the account name.
   Public Function GetThreadAccountName() As String
        Return String.Format( _
        "Request user host address: {0}", _
        ThreadInformation.ThreadAccountName)
   End Function 'GetThreadAccountName
   
   ' Get the task Id.
   Public Function GetThreadId() As String
      ' Get the request principal.
        Return String.Format( _
        "Thread Id: {0}", _
        ThreadInformation.ThreadID.ToString())
   End Function 'GetThreadId
   
   ' Formats Web request event information.
    Public Overrides Sub FormatCustomEventDetails( _
    ByVal formatter As WebEventFormatter)

        ' Add custom data.
        formatter.AppendLine("")
        formatter.AppendLine( _
        "Custom Thread Information:")

        formatter.IndentationLevel += 1

        ' Display the thread information obtained 
        formatter.AppendLine(GetThreadImpersonation())
        formatter.AppendLine(GetThreadStackTrace())
        formatter.AppendLine(GetThreadAccountName())
        formatter.AppendLine(GetThreadId())
        formatter.IndentationLevel -= 1

        formatter.AppendLine(eventInfo.ToString())
    End Sub

End Class

Açıklamalar

ASP.NET sistem durumunu izleme, üretim ve operasyon personelinin dağıtılan Web uygulamalarını yönetmesine olanak tanır. Ad alanı, System.Web.Management uygulama sistem durumu verilerini paketlemeden sorumlu sistem durumu olay türlerini ve bu verileri işlemeden sorumlu sağlayıcı türlerini içerir. Ayrıca, sistem durumu olaylarının yönetimi sırasında yardımcı olan destekleyici türler içerir.

sınıfının örnekleriWebThreadInformation, türü veya WebErrorEvent türü kullanılarak WebRequestErrorEvent elde edilen bilgileri içerir.

Uygulamanızın bu tür tarafından sağlanan korumalı bilgilere erişmek için uygun izinlere sahip olması gerekir.

Note

Çoğu durumda, uygulanan ASP.NET sistem durumu izleme türlerini kullanabilir ve healthMonitoring yapılandırma bölümünde değerleri belirterek sistem durumu izleme sistemini denetleyebilirsiniz. Kendi özel olaylarınızı ve sağlayıcılarınızı oluşturmak için sistem durumu izleme türlerinden de türetebilirsiniz. Özel olay sınıfı oluşturma örneği için bu konu başlığında sağlanan örne bakın.

Özellikler

Name Description
IsImpersonating

Geçerli iş parçacığı kimliğe bürünme modunu alır.

StackTrace

Geçerli iş parçacığı tarafından yönetilen yığın izlemesini alır.

ThreadAccountName

İş parçacığı hesap adını alır.

ThreadID

Geçerli iş parçacığı tanımlayıcısını alır.

Yöntemler

Name Description
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
FormatToString(WebEventFormatter)

İş parçacığıyla ilgili bilgileri biçimlendirır.

GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden bir dize döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır

Ayrıca bkz.