Hello there,
I have spent many hours trying to figure out which source code to use.
I have two sources that are totally different but do the exact same thing that I'm looking for.
the code checks for processed log files based on (every minute) basis.
which approach is better if lets say i'm processing 100,000 logs per minute..
Public Class Form1 Dim myValues As New List(Of Dictionary(Of String, Date))() Dim iCount As Long Private Sub cmdButton_Click(sender As Object, e As EventArgs) Handles cmdButton.Click myValues.Add(New Dictionary(Of String, Date)() From {{"logname", DateTime.Now}}) End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick iCount = 0 For Each value As Dictionary(Of String, Date) In myValues If value.First.Key.ToString = "logname" Then If (value("logname") >= DateTime.Now.AddMinutes(-1)) Then iCount += 1 End If End If Next Label.Text = iCount End SubEnd Class
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:
Select All Code
Public Class Form1 Dim processed_files As List(Of processed_log_file) = New List(Of processed_log_file) Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click processed_files.Add(New processed_log_file("logname", DateTime.Now)) Dim sublist As List(Of processed_log_file) sublist = processed_files.FindAll(AddressOf IsFromLast24h) lblLast24Hrs.Text = sublist.Count End Sub Function IsFromLast24h(ByVal b As processed_log_file) As Boolean If (b.processed_date >"= DateTime.Now.AddDays(-1)) Then Return True Else Return False End If End FunctionEnd ClassPublic Class processed_log_file Public file_name As String Public processed_date As Date Public Sub New(ByVal m_file_name As String, ByVal m_processed_date As Date) file_name = m_file_name processed_date = m_processed_date End SubEnd 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:
Select All Code