public void SubThreadCreator() { int subServerCapacity70 = Convert.ToInt32(SubServerCapacity * percentage); while (true) { for (int i = 0; i < SubServers.Count; i++) { SubServer subServer = SubServers[i]; if (subServer.requestsSub.Count > subServerCapacity70) { SubServer subServerNew = new SubServer(this); SubServers.Add(subServerNew); int half = subServer.requestsSub.Count / 2; for (int j = 0; j < half; j++) { if (subServer.requestsSub.Count > 0 && subServerNew.requestsSub.Count < 5000) { try { subServerNew.requestsSub.Add(subServer.requestsSub.ElementAt(subServer.requestsSub.Count - 1)); subServer.requestsSub.RemoveAt(subServer.requestsSub.Count - 1); } catch (Exception) { } } else { break; } } subServerNew.subServerThread.Start(); } else if (subServer.requestsSub.Count < 1 && SubServers.Count > 2) { subServer.subServerThread.Abort(); BeginInvoke((MethodInvoker) delegate { subServer.panel.Controls.Clear(); flowLayoutPanelSubServers.Controls.Remove(subServer.panel); }); SubServers.RemoveAt(i); } } } }
public void RunServerSpotter() { while (true) { WritePBValueSafe(pBMainServer, requestsMain.Count); WriteTextSafe(lblMainserverPrc, requestsMain.Count.ToString() + " / " + MainServerCapacity); for (int i = 0; i < SubServers.Count; i++) { SubServer subServer = SubServers[i]; WritePBValueSafe(subServer.subProgressBar, subServer.requestsSub.Count); WriteTextSafe(subServer.subLabel2, subServer.requestsSub.Count.ToString() + " / " + SubServerCapacity); } } }