I am calling this function several thousands times per minute to get an average of latency but after running for about 20 or 30 minutes my app crashes.. any idea why is this happening?
Source array was not long enough. Check srcIndex and length, and the array's lower bounds.
Dim iLatency_Average As New List(Of Long)
Public Function Average_Latency(myLatency As Long) As Long
iLatency_Average.Insert(0, myLatency)
If iLatency_Average.Count = 25 Then
Dim allLatency() As Long = iLatency_Average.ToArray()
Array.Sort(allLatency)
Dim iAverage As Long
For i As Integer = 5 To 19
iAverage += allLatency(i)
Next
iLatency_Average.RemoveAt(24)
Return CLng(iAverage / 15)
Else
Return 0
End If
End Function