Click here to Skip to main content
15,896,437 members
Articles / Programming Languages / Visual Basic

Application dashboard for tracking .NET application performance

Rate me:
Please Sign up or sign in to vote.
3.39/5 (12 votes)
26 Jul 2006CPOL 94.6K   3.1K   50  
Provides graphical feedback on the performance (memory usage, garbage collection, threads, exceptions, loaded classes) of a .NET application.
Imports System.Windows.Forms
Imports System.Diagnostics

Public Class SettingsForm

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add all the running instances of .NET apps to the drop down list
        If PerformanceCounterCategory.CounterExists("# GC Handles", Form_Dashboard.COUNTER_CATEGORY_MEMORY) Then
            Dim pcInst As New PerformanceCounterCategory(Form_Dashboard.COUNTER_CATEGORY_MEMORY)
            With pcInst
                Dim Items() As String = .GetInstanceNames
                For Each f As String In Items
                    Me.ComboBox_ApplicationInstances.Items.Add(f)
                Next
            End With
        End If

        Try
            If My.Settings.MonitoredInstanceName <> "" Then
                Me.ComboBox_ApplicationInstances.SelectedItem = My.Settings.MonitoredInstanceName
            End If
        Catch ex As Exception
            Debug.Fail(ex.ToString)
        End Try

        With My.Settings
            Me.TextBox_Max_Classes.Text = .DialClassesMaximum.ToString
            Me.TextBox_Max_Exceptions.Text = .DialExceptionsMaximum.ToString
            Me.TextBox_Max_Garbage.Text = .DialGarbageMaximum.ToString
            Me.TextBox_Max_Memory.Text = .DialMemoryMaximum.ToString
            Me.TextBox_Max_Threads.Text = .DialThreadsMaximum.ToString
            Me.TextBox_Min_Classes.Text = .DialClassesMinimum.ToString
            Me.TextBox_Min_Exceptions.Text = .DialExceptionsMinimum.ToString
            Me.TextBox_Min_Garbage.Text = .DialGarbageMinimum.ToString
            Me.TextBox_Min_Memory.Text = .DialMemoryMinimum.ToString
            Me.TextBox_Min_Threads.Text = .DialThreadsMinimum.ToString
        End With

    End Sub

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Public ReadOnly Property SelectedInstanceName() As String
        Get
            Return Me.ComboBox_ApplicationInstances.Text
        End Get
    End Property

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Ireland Ireland
C# / SQL Server developer
Microsoft MVP (Azure) 2017
Microsoft MVP (Visual Basic) 2006, 2007

Comments and Discussions