static public async Task <List <SpeedTestClient.Result> > RunSpeedTestWithMultiTryAsync(TcpIpSystem system, IPAddress ip, int port, int numConnection, int timespan, SpeedTestModeFlag mode, int numTry, int interval, CancellationToken cancel = default) { List <SpeedTestClient.Result> ret = new List <Result>(); numTry = Math.Max(numTry, 1); for (int i = 0; i < numTry; i++) { if (cancel.IsCancellationRequested) { return(new List <Result>()); } SpeedTestClient tc = new SpeedTestClient(system, ip, port, numConnection, timespan, mode, cancel); var result = await tc.RunClientAsync(); if (result != null) { ret.Add(result); } await cancel._WaitUntilCanceledAsync(Util.GenRandInterval(interval)); } return(ret); }
static void Net_Test4_SpeedTest_Client() { string hostname = "speed.coe.ad.jp"; CancellationTokenSource cts = new CancellationTokenSource(); var client = new SpeedTestClient(LocalNet, LocalNet.GetIp(hostname), 9821, 1, 30000, SpeedTestModeFlag.Download, cts.Token); var task = client.RunClientAsync(); //Con.ReadLine("Enter to stop>"); ////int wait = 2000 + Util.RandSInt32_Caution() % 1000; ////Con.WriteLine("Waiting for " + wait); ////ThreadObj.Sleep(wait); //Con.WriteLine("Stopping..."); //cts._TryCancelNoBlock(); task._GetResult()._PrintAsJson(); Con.WriteLine("Stopped."); }