多年代码搬运工 2022-09-04 01:07 采纳率: 60%
浏览 38
已结题

关于#WPF#的问题,如何解决?

刚接触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

```

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 已结题 9月22日
      • 已采纳回答 9月22日
      • 创建了问题 9月4日

      悬赏问题

      • ¥15 一块GD32F105芯片的主板。怎么找RXD和TXD串口
      • ¥15 磁盘异常导致工业相机GigE传图卡顿
      • ¥20 python中使用chatgpt为什么一直连接失败
      • ¥50 使用grpc遇到的问题
      • ¥100 运算速度优化问题,控制在四秒以内
      • ¥15 如何用matlab画出这样的图
      • ¥15 线性回归问题进行特征缩放后,为什么求得的参数不对了
      • ¥15 python爬取网页信息(主要为期刊影响因子、官网等),已有ISSN进行检索,但爬取过程找不到class该怎么办?
      • ¥15 找出5阶幻方的所有解的个数:275305224
      • ¥20 wireshark无网络波动