我的类启动新进程(Tshark)并开始捕获,从主窗体我检查类属性以更新我的 GUI,有时接收到的数据包率太高以至于我的 GUI 卡住了,所以我想要检查谁的属性的选项每 1-2 秒。这是我的进度更改功能,它一直在检查我的课程,此时我正在更新我的 GUI,我如何每 2 秒检查一次这些属性?
Tshark tshark = new Tshark();
private void bgWSniffer_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
tshark = e.UserState as Tshark;
lblNumberOfReceivedPackets.Text = tshark._receivesPackets.ToString("#,##0");
lblTrafficRate.Text = (tshark._bitsPerSecond * 0.000001).ToString("0.##") + " Mbit/sec" + " (" + tshark._bitsPerSecond.ToString("#,##0") + " Bits/sec" + ")";
lblPacketsRate.Text = tshark._packetsPerSecond.ToString("#,##0") + " Packets/sec";
lblStatus.Text = tshark._status;
lblFileSize.Text = formatBytes(tshark._myFile.Length);
tshark._myFile.Refresh();
}