本文整理匯總了VB.NET中System.Web.Management.WebThreadInformation類的典型用法代碼示例。如果您正苦於以下問題:VB.NET WebThreadInformation類的具體用法?VB.NET WebThreadInformation怎麽用?VB.NET WebThreadInformation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了WebThreadInformation類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: SampleWebThreadInformation
' 導入命名空間
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