Beispiel #1
0
        private async Task UntilStoppedPingAsync(PingModel pingModel, PingSettings setting, CancellationToken token)
        {
            while (pingModel.IsWorking)
            {
                try
                {
                    var newPing = await this.EchoRequestAsync(setting.Host, setting.BufferLength, setting.Ttl, setting.TimeOut, token);

                    pingModel.Add(newPing);
                    await Task.Delay(500);
                }
                catch (OperationCanceledException)
                {
                    break;
                }
            }
        }
Beispiel #2
0
        private async Task CountPingAsync(PingModel ping, PingSettings setting, CancellationToken token)
        {
            for (int i = 0; i < setting.RequestNumber && ping.IsWorking; i++)
            {
                try
                {
                    var newPing = await this.EchoRequestAsync(setting.Host, setting.BufferLength, setting.Ttl, setting.TimeOut, token);

                    ping.Add(newPing);
                    await Task.Delay(500);
                }
                catch (OperationCanceledException)
                {
                    break;
                }
            }
        }