我想用开始和停止按钮制作 Pinger,我从这个论坛获得的这段代码就像 stopLoop:
private bool _stopLoop;
private void button1_Click(object sender, EventArgs e)
{
_stopLoop = false;
for (int i = 0; i < 100000 && !_stopLoop; ++i)
{
using (Ping p = new Ping())
{
lbPing.Text = p.Send(tbUrl.Text).RoundtripTime.ToString() + "ms\n";
lbPing.Update();
}
}
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x84:
base.WndProc(ref m);
if ((int)m.Result == 0x1)
m.Result = (IntPtr)0x2;
return;
}
base.WndProc(ref m);
}
private void btStop_Click(object sender, EventArgs e)
{
_stopLoop = true;
}
元芳怎么了
HUH函数
Cats萌萌
慕姐8265434
随时随地看视频慕课网APP
相关分类