private static void Run161() { if (_useDelay) { Thread.Sleep(_delayCount); } int count = 0; Console.WriteLine("========================="); var result = _redisClient4.FlushDBAsync().Result; Console.WriteLine($"Clear DB 0 - [{(result ? "SUCCEED" : "FAILED")}]!"); var tasks = new Task <bool> [frequence]; Stopwatch sw = new Stopwatch(); //_beforeSw?.Invoke(title); Console.WriteLine("Start Run:"); //Thread.Sleep(0); //Thread.Sleep(1000); sw.Start(); Parallel.For(0, frequence, _options, (index) => { var key = index.ToString(); tasks[index] = _redisClient161.SetAsync(key, key); }); //Task.WaitAll(tasks); int offset = 0; SpinWait wait = default; while (offset != frequence - 1) { for (int i = offset; i < frequence; i++) { if (tasks[i].IsCompleted) { offset = i; } else { break; } } wait.SpinOnce(); } sw.Stop(); //Thread.Sleep(3000); //var checkTasks = new Task[frequence]; //for (var a = 0; a < frequence; a += 1) //{ // var key = a.ToString(); // checkTasks[a] = Task.Run(() => // { // var result = _stackExnchangeClient.StringGet(key); // if (result != key) // { // Console.WriteLine(key); // Console.WriteLine(result); // Interlocked.Increment(ref count); // } // }); //} //Task.WaitAll(checkTasks); //Console.WriteLine($"{title} (0-{frequence / 10000}W) : {sw.ElapsedTicks} SPAN! "); Console.WriteLine($"161 (0-{frequence / 10000}W) : {sw.ElapsedMilliseconds}ms! "); //Console.WriteLine($"Errors : {count} !"); //if (count>0) //{ // Thread.Sleep(1000); // for (var a = 0; a < frequence; a += 1) // { // var key = a.ToString(); // tasks[a] = Task.Run(() => // { // var result = _stackExnchangeClient.StringGet(key); // if (result != key) // { // Interlocked.Increment(ref count); // } // }); // } // Task.WaitAll(tasks); // Console.WriteLine($"Rechecking Errors : {count} !"); //} Console.WriteLine("=========================\r\n"); }