Here's another one that builds a summary for each distinct host:
Public Class Form1
Private PingResponse As New Dictionary(Of Integer, clsPingResp)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MakeNewSampleData()
Dim msg As New System.Text.StringBuilder
For Each Host In From cpr In PingResponse.Values Select cpr.strHost Distinct
Dim CurHost As String = Host
Dim Response = Aggregate responses _
In (From cpr In PingResponse.Values _
Where cpr.strHost = CurHost) _
Into NumResponses = Count(responses.ResponseTime), _
MinResponse = Min(responses.ResponseTime), _
MaxResponse = Max(responses.ResponseTime), _
AvgResponse = Average(responses.ResponseTime)
msg.AppendLine("Host: " & CurHost)
msg.AppendLine("# Responses: " & Response.NumResponses)
msg.AppendLine("Min Response Time: " & Response.MinResponse)
msg.AppendLine("Max Response Time: " & Response.MaxResponse)
msg.AppendLine("Avg Response Time: " & Response.AvgResponse)
msg.AppendLine("--------------------------------------------")
Next
MessageBox.Show(msg.ToString, "Response Summary", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub MakeNewSampleData()
Static R As New Random
Static Hosts() As String = {"a.a.a.a", "b.b.b.b", "c.c.c.c", "d.d.d.d"}
PingResponse.Clear()
For i As Integer = 0 To Hosts.GetUpperBound(0)
Dim min As Integer = R.Next(1, 51)
Dim max As Integer = R.Next(50, 101)
For j As Integer = 1 To R.Next(100, 501)
PingResponse.Add(i * 1000 + j, New clsPingResp() With {.strHost = Hosts(i), .ResponseTime = R.Next(min, max)})
Next
Next
End Sub
End Class
Public Class clsPingResp
Public strHost As String
Public ResponseTime As Integer
End Class
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49:
- ReponseSummary.jpg
- 80 KB
Response Summary for All Hosts in Dictionary





by: Idle_MindPosted on 2009-08-29 at 14:23:33ID: 25215410
Hi again Eric!
Play with this simple example... =)
Select allOpen in new window