private void ScanArchors(string[] cmds, string[] ips) { this.Cmds = cmds; this.Ips = ips; if (arg.Ping) { resultList.ClearPing(Ips); if (pingEx == null) { pingEx = new PingEx(); pingEx.ProgressChanged += PingEx_ProgressChanged; pingEx.Error += (ex) => { AddLog(ex.ToString()); }; } pingEx.WaitTime = arg.PingWaitTime; pingEx.SetData(arg.PingLength); pingEx.PingRange(Ips, arg.PingCount); } else { worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker.WorkerReportsProgress = true; worker.DoWork += Worker_DoWork; worker.ProgressChanged += Worker_ProgressChanged; worker.RunWorkerAsync(); } //Ping ping = new Ping(); //ping. }
private void StartPing() { var ip = TbIp.Text; int count = TbCount.Text.ToInt(); PingEx pingSender = new PingEx(); pingSender.ProgressChanged += (p, pr) => { TbConsole1.Text += pr.Line + "\n"; }; pingSender.SetData(TbSize.Text.ToInt()); pingSender.Ping(ip, count); }
private void CheckDatacaseWebApiUrl(string host, string port) { var apiUrl = AppContext.DatacaseWebApiUrl; if (!string.IsNullOrEmpty(apiUrl)) { WriteLog("配置对接WebApi地址:" + apiUrl); if (apiUrl == "simulate") { AppContext.DatacaseWebApiUrl = string.Format("{0}:{1}/datacase", host, port); } else { var r = PingEx.Send(apiUrl); if (r == false) { WriteLog("无法Ping通该地址:" + apiUrl); AppContext.DatacaseWebApiUrl = string.Format("{0}:{1}/datacase", host, port); } } WriteLog("最终对接WebApi地址:" + AppContext.DatacaseWebApiUrl); } }
private void BtnStartRange_Click(object sender, RoutedEventArgs e) { var ip = TbIp.Text; int count = TbCount.Text.ToInt(); pingSender = new PingEx(); pingSender.ProgressChanged += (p, pr) => { if (p > 0) { ProgressBarEx1.Value = p; TbConsole1.Text = pr.Line + "\n" + TbConsole1.Text; } else { if (!string.IsNullOrEmpty(pr.ResultText)) { TbConsole2.Text = pr.ResultText + "\n" + TbConsole2.Text; } } }; pingSender.SetData(TbSize.Text.ToInt()); pingSender.PingRange(ip, count); }