刚接触VB没几天,我这有一段WPF的项目代码,希望能帮我解读一下第一段代码的相关语法,要是能参照其他语言解读更好
```vb.net
tcpHelper1 = New TcpHelper(theSetting.TheEndPiont1) With {.DataHandler = Function(Data As String, sourceSocket As Socket) As Integer
Debug.WriteLine(Data)
For Each m As Match In Regex.Matches(Data, "#[0-9a-zA-Z]{39}")
'Debug.WriteLine(m.Value)
Dim id As String = m.Value.Substring(21, 10)
'回应并过滤掉心跳包
If Regex.IsMatch(id, "0{10}") Then
Dim buffer() As Byte = Encoding.UTF8.GetBytes("#ACK " & Now.ToString("yyyy/MM/dd HH:mm:ss"))
sourceSocket.Send(buffer)
Return 0
End If
Dim timeStr As String = m.Value.Substring(9, 12)
'Debug.WriteLine(ftimestr)
Dim time As Date = Convert.ToDateTime(ftimestr)
Debug.WriteLine("卡号:" & id & "时间:" & time.ToString)
Me.Dispatcher.Invoke(Sub()
If viewData.Data.Select(Function(i) i.Rfid).Contains(id) Then
Dim curMan As SportsMan = viewData.Data.Where(Function(i) i.Rfid = id).First
If curMan.Didnotfinish = False Then
If (time - curMan.LastTagTime1).TotalSeconds > CInt(theSetting.MinTime) Then
If curMan.Round1 < theSetting.TotalRounds Then
curMan.Round1 += 1
If theSetting.ShowRound1 = True Then viewData.Data = New ObservableCollection(Of SportsMan)(viewData.Data.OrderByDescending(Function(i)
Return i.Round1
End Function).OrderBy(Function(i) i.Didnotfinish).Select(Function(i, index)
i.Order = index + 1
Return i
End Function))
curMan.LastTagTime1 = time
End If
End If
End If
End If
End Sub)
Next
Return 0
End Function}
Try
tcpHelper1.Start()
Catch ex As Exception
status_Txb1.Text = ex.Message
End Try
```