本文整理汇总了VB.NET中System.Web.Management.WmiWebEventProvider类的典型用法代码示例。如果您正苦于以下问题:VB.NET WmiWebEventProvider类的具体用法?VB.NET WmiWebEventProvider怎么用?VB.NET WmiWebEventProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WmiWebEventProvider类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: DisplayEventInformation
' 导入命名空间
Imports System.Management
' Capture WMI events associated with
' ASP.NET health monitoring types.
Class SampleWmiWebEventListener
'Displays event related information.
Shared Sub DisplayEventInformation(ByVal ev _
As ManagementBaseObject)
' It contains the name of the WMI raised
' event. This is the name of the
' event class as defined in the
' Aspnet.mof file.
Dim eventTypeName As String
' Get the name of the WMI raised event.
eventTypeName = ev.ClassPath.ToString()
' Process the raised event.
Select Case eventTypeName
' Process the heartbeat event.
Case "HeartBeatEvent"
Console.WriteLine("HeartBeat")
Console.WriteLine(vbTab + _
"Process: {0}", ev("ProcessName"))
Console.WriteLine(vbTab + "App: {0}", _
ev("ApplicationUrl"))
Console.WriteLine(vbTab + "WorkingSet: {0}", _
ev("WorkingSet"))
Console.WriteLine(vbTab + "Threads: {0}", _
ev("ThreadCount"))
Console.WriteLine(vbTab + "ManagedHeap: {0}", _
ev("ManagedHeapSize"))
Console.WriteLine(vbTab + "AppDomainCount: {0}", _
ev("AppDomainCount"))
' Process the request error event.
Case "RequestErrorEvent"
Console.WriteLine("Error")
Console.WriteLine("Url: {0}", _
ev("RequestUrl"))
Console.WriteLine("Path: {0}", _
ev("RequestPath"))
Console.WriteLine("Message: {0}", _
ev("EventMessage"))
Console.WriteLine("Stack: {0}", _
ev("StackTrace"))
Console.WriteLine("UserName: {0}", _
ev("UserName"))
Console.WriteLine("ThreadID: {0}", _
ev("ThreadAccountName"))
' Process the application lifetime event.
Case "ApplicationLifetimeEvent"
Console.WriteLine("App Lifetime Event {0}", _
ev("EventMessage"))
' Handle events for which processing is not
' provided.
Case Else
Console.WriteLine("ASP.NET Event {0}", _
ev("EventMessage"))
End Select
End Sub
' End DisplayEventInformation.
' The main entry point for the application.
Shared Sub Main(ByVal args() As String)
' Get the name of the computer on
' which this program runs.
' Note. The monitored application must also run
' on this computer.
Dim machine As String = Environment.MachineName
' Define the Common Information Model (CIM) path
' for WIM monitoring.
Dim path As String = _
String.Format("\\{0}\root\aspnet", machine)
' Create a managed object watcher as
' defined in System.Management.
Dim query As String = "select * from BaseEvent"
Dim watcher As New ManagementEventWatcher(query)
' Set the watcher options.
Dim timeInterval As New TimeSpan(0, 1, 30)
watcher.Options = _
New EventWatcherOptions(Nothing, timeInterval, 1)
' Set the scope of the WMI events to
' watch to be ASP.NET applications.
watcher.Scope = _
New ManagementScope(New ManagementPath(path))
' Set the console background.
Console.BackgroundColor = ConsoleColor.Blue
' Set foreground color.
Console.ForegroundColor = ConsoleColor.Yellow
' Clear the console.
Console.Clear()
' Loop indefinitely to catch the events.
Console.WriteLine( _
"Listener started. Enter CntlC to terminate")
While True
Try
' Capture the WMI event related to
' the Web event.
Dim ev As ManagementBaseObject = _
watcher.WaitForNextEvent()
' Display the Web event information.
DisplayEventInformation(ev)
' Prompt the user.
Console.Beep()
Catch e As Exception
Console.WriteLine("Error: {0}", e)
Exit While
End Try
End While
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Web.Management,代码行数:133,代码来源:WmiWebEventProvider
注:本文中的System.Web.Management.WmiWebEventProvider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论