private void updateListBackThread(view baseView, ListView serverView, ToolStripLabel toolStripLabel, StatusStrip SS, Servers serversInstance, Protocol.Protocol protocolInstance, String ipport) { if (baseView.serversInstance.masterServers.ContainsKey(ipport) == false) { baseView.serversInstance.masterServers.Add(ipport, new Server()); } Server serv = baseView.serversInstance.masterServers[ipport]; protocolInstance.updateServerInfo(serv, Protocol.Protocol.basic); changeCurrThread(-1, true); }
public void updateAllServersThread(view baseView, ListView serverView, ToolStripLabel toolStripLabel, StatusStrip SS, Servers serversInstance, Protocol.Protocol protocolInstance, bool selectedOnly, bool serverViewOnly) { killThreads = false; int maxthreads = 90; changeCurrThread(0, false); int count = 0; var updateList = new List <string>(); int max = 0; //refresh selected in server view if (selectedOnly && serverViewOnly) { ListView.SelectedListViewItemCollection SLVIC = serverView.SelectedItems; max = SLVIC.Count; foreach (ListViewItem LVI in SLVIC) { updateList.Add(LVI.Name); } } //refresh all in server view else if (selectedOnly == false && serverViewOnly) { max = serverView.Items.Count; foreach (ListViewItem LVI in serverView.Items) { updateList.Add(LVI.Name); } } //otherwise refresh all in database else { max = serversInstance.masterServers.Keys.Count; foreach (String s in serversInstance.masterServers.Keys) { updateList.Add(s); } } foreach (String s in updateList) { if (selectedOnly && serverViewOnly == false && serverView.Items.ContainsKey(s) == false) { continue; } retry: if (killThreads) { break; } if (currthreads > maxthreads) { Thread.Sleep(100); goto retry; } changeCurrThread(1, true); Thread t; if (serverViewOnly) { t = new Thread( () => updateListServerViewThread(baseView, serverView, toolStripLabel, SS, serversInstance, protocolInstance, s)); } else { t = new Thread( () => updateListBackThread(baseView, serverView, toolStripLabel, SS, serversInstance, protocolInstance, s)); } t.Start(); Controller.ToolStripText(toolStripLabel, ref SS, "Updating " + count.ToString() + "/" + max.ToString()); count++; } while (currthreads > 0) { Thread.Sleep(100); } Controller.ToolStripText(toolStripLabel, ref SS, "Ready"); killThreads = false; }
public threads(view newBaseView) { baseView = newBaseView; }
public static void ServersFromFile(ToolStripLabel toolStripLabel, StatusStrip ss, Servers serversInstance, threads threadsInstance, ListView serverView, view baseView) { var ofd = new OpenFileDialog(); ofd.Title = "Select file to extract ip:ports from"; ofd.ShowDialog(); if (string.IsNullOrEmpty(ofd.FileName)) return; var fs = new FileStream(ofd.FileName, FileMode.Open); var sr = new StreamReader(fs); String file = sr.ReadToEnd(); sr.Close(); fs.Close(); threadsInstance.addServerCollectionThread(toolStripLabel, ref ss, file, serversInstance, threadsInstance); ToolStripText(toolStripLabel, ref ss, "Ready"); baseView.allServersToServerView(); }
public static async Task ServersFromUrl(ToolStripLabel toolStripLabel, StatusStrip ss, Servers serversInstance, threads threadsInstance, ListView serverView, view baseView) { var sb = new getStringBox(); sb.label1.Text = "Enter URL to extract ip:ports from"; sb.ShowDialog(); String ret = sb.returnvalue; if (ret == "") return; ToolStripText(toolStripLabel, ref ss, "Extracting Web Page Text"); var page = await NetExtras.DownloadWebPage(ret); if (page == null) { MessageBox.Show("Not a valid webpage"); return; } threadsInstance.addServerCollectionThread(toolStripLabel, ref ss, page, serversInstance, threadsInstance); ToolStripText(toolStripLabel, ref ss, "Ready"); baseView.allServersToServerView(); }
public ExtraInfo(view newBaseView) { InitializeComponent(); baseView = newBaseView; }
private void updateListServerViewThread(view baseView, ListView serverView, ToolStripLabel toolStripLabel, StatusStrip SS, Servers serversInstance, Protocol.Protocol protocolInstance, String ipport) { if (baseView.serversInstance.masterServers.ContainsKey(ipport) == false) baseView.serversInstance.masterServers.Add(ipport, new Server()); Server serv = baseView.serversInstance.masterServers[ipport]; protocolInstance.updateServerInfo(serv, Protocol.Protocol.basic); Controller.UpdateServerInServerView(serv, serverView); changeCurrThread(-1, true); }
public void updateAllServersThread(view baseView, ListView serverView, ToolStripLabel toolStripLabel, StatusStrip SS, Servers serversInstance, Protocol.Protocol protocolInstance, bool selectedOnly, bool serverViewOnly) { killThreads = false; int maxthreads = 90; changeCurrThread(0, false); int count = 0; var updateList = new List<string>(); int max = 0; //refresh selected in server view if (selectedOnly && serverViewOnly) { ListView.SelectedListViewItemCollection SLVIC = serverView.SelectedItems; max = SLVIC.Count; foreach (ListViewItem LVI in SLVIC) { updateList.Add(LVI.Name); } } //refresh all in server view else if (selectedOnly == false && serverViewOnly) { max = serverView.Items.Count; foreach (ListViewItem LVI in serverView.Items) { updateList.Add(LVI.Name); } } //otherwise refresh all in database else { max = serversInstance.masterServers.Keys.Count; foreach (String s in serversInstance.masterServers.Keys) { updateList.Add(s); } } foreach (String s in updateList) { if (selectedOnly && serverViewOnly == false && serverView.Items.ContainsKey(s) == false) continue; retry: if (killThreads) break; if (currthreads > maxthreads) { Thread.Sleep(100); goto retry; } changeCurrThread(1, true); Thread t; if (serverViewOnly) t = new Thread( () => updateListServerViewThread(baseView, serverView, toolStripLabel, SS, serversInstance, protocolInstance, s)); else t = new Thread( () => updateListBackThread(baseView, serverView, toolStripLabel, SS, serversInstance, protocolInstance, s)); t.Start(); Controller.ToolStripText(toolStripLabel, ref SS, "Updating " + count.ToString() + "/" + max.ToString()); count++; } while (currthreads > 0) { Thread.Sleep(100); } Controller.ToolStripText(toolStripLabel, ref SS, "Ready"); killThreads = false; }
public static async Task ServersFromUrl(ToolStripLabel toolStripLabel, StatusStrip ss, Servers serversInstance, threads threadsInstance, ListView serverView, view baseView) { var sb = new getStringBox(); sb.label1.Text = "Enter URL to extract ip:ports from"; sb.ShowDialog(); String ret = sb.returnvalue; if (ret == "") { return; } ToolStripText(toolStripLabel, ref ss, "Extracting Web Page Text"); var page = await NetExtras.DownloadWebPage(ret); if (page == null) { MessageBox.Show("Not a valid webpage"); return; } threadsInstance.addServerCollectionThread(toolStripLabel, ref ss, page, serversInstance, threadsInstance); ToolStripText(toolStripLabel, ref ss, "Ready"); baseView.allServersToServerView(); }
public static void ServersFromFile(ToolStripLabel toolStripLabel, StatusStrip ss, Servers serversInstance, threads threadsInstance, ListView serverView, view baseView) { var ofd = new OpenFileDialog(); ofd.Title = "Select file to extract ip:ports from"; ofd.ShowDialog(); if (string.IsNullOrEmpty(ofd.FileName)) { return; } var fs = new FileStream(ofd.FileName, FileMode.Open); var sr = new StreamReader(fs); String file = sr.ReadToEnd(); sr.Close(); fs.Close(); threadsInstance.addServerCollectionThread(toolStripLabel, ref ss, file, serversInstance, threadsInstance); ToolStripText(toolStripLabel, ref ss, "Ready"); baseView.allServersToServerView(); }