Skip to content

Commit

Permalink
Multi-threading for Newly Listed
Browse files Browse the repository at this point in the history
wow such multi
  • Loading branch information
Maxx53 committed Oct 6, 2014
1 parent 8f4cab5 commit bb20255
Show file tree
Hide file tree
Showing 16 changed files with 1,465 additions and 1,209 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions scr/SCMBot/ProxyStatsFrm.cs → scr/SCMBot/HostStatsFrm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace SCMBot
{
public partial class ProxyStatsFrm : Form
public partial class HostStatsFrm : Form
{
public ProxyStatsFrm()
public HostStatsFrm()
{
InitializeComponent();
}
Expand All @@ -18,7 +18,7 @@ private void timer1_Tick(object sender, EventArgs e)

for (int i = 0; i < Main.hostList.Count; i++)
{
string[] row = { Main.hostList[i].Host, Main.hostList[i].InUsing.ToString(), Main.hostList[i].WorkLoad.ToString() };
string[] row = { Main.hostList[i].Host, Main.hostList[i].InUsing.ToString(), Main.hostList[i].WorkLoad.ToString(), Main.hostList[i].Pingas };
var lstItem = new ListViewItem(row);
if (Main.hostList[i].InUsing)
lstItem.BackColor = Color.OrangeRed;
Expand All @@ -32,6 +32,7 @@ private void timer1_Tick(object sender, EventArgs e)
private void ProxyStatsFrm_Load(object sender, EventArgs e)
{
ListViewHelper.EnableDoubleBuffer(listView1);
this.Icon = Icon.FromHandle(Properties.Resources.host.GetHicon());
}

private void ProxyStatsFrm_Shown(object sender, EventArgs e)
Expand Down
File renamed without changes.
501 changes: 253 additions & 248 deletions scr/SCMBot/Main.Designer.cs

Large diffs are not rendered by default.

26 changes: 20 additions & 6 deletions scr/SCMBot/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Net.NetworkInformation;


// Внимание! Данная наработка - всего-лишь грубая реализация идеи.
Expand Down Expand Up @@ -43,7 +44,7 @@ public partial class Main : Form
public static ScanItemList scanItems = new ScanItemList();

private SettingsFrm settingsForm = new SettingsFrm();
private ProxyStatsFrm proxyStatForm = new ProxyStatsFrm();
private HostStatsFrm proxyStatForm = new HostStatsFrm();
private GraphFrm graphFrm = new GraphFrm();

Properties.Settings settings = Properties.Settings.Default;
Expand Down Expand Up @@ -87,7 +88,6 @@ public Main()

private void Main_Load(object sender, EventArgs e)
{
Application.DoEvents();

settingsForm.intLangComboBox.DataSource = new System.Globalization.CultureInfo[]
{
Expand Down Expand Up @@ -140,7 +140,11 @@ private void Main_Load(object sender, EventArgs e)
Match match = Regex.Match(plines[i], ipPattern);
if (match.Success)
{
hostList.Add(plines[i]);
Application.DoEvents();
Ping ping = new Ping();
PingReply pingReply = ping.Send(plines[i]);
hostList.Add(plines[i], pingReply.RoundtripTime.ToString());
StatusLabel1.Text = "Loading hosts... "+i.ToString() + " of " + plines.Length.ToString();
}
}
StatusLabel1.Text = "Hosts loaded: " + hostList.Count.ToString();
Expand Down Expand Up @@ -199,6 +203,9 @@ private void LoadSettings(bool loadtabs)
settingsForm.searchResBox.Text = settings.searchRes;
settingsForm.ignoreBox.Checked = settings.ignoreWarn;
settingsForm.actualBox.Checked = settings.loadActual;
settingsForm.listedCountNumeric.Value = settings.listedCount;
settingsForm.reqCountNumeric.Value = settings.reqCount;


isHTML = settings.scanHTML;
settingsForm.scanHtlmBox.Checked = settings.scanHTML;
Expand Down Expand Up @@ -277,7 +284,10 @@ private void LoadSettings(bool loadtabs)
if (reqPool != null)
reqPool.Dispose();

reqPool = new Semaphore(1, 1);
int num = settings.reqCount;
if (num <= 0)
num = 5;
reqPool = new Semaphore(num, num);
}
}

Expand Down Expand Up @@ -306,7 +316,9 @@ private void SaveSettings(bool savetabs)
settings.hideInvent = settingsForm.hideInventBox.Checked;
settings.logCount = Convert.ToInt32(settingsForm.logCountBox.Text);
settings.resellDelay = Convert.ToInt32(settingsForm.resDelayBox.Text);

settings.listedCount = (int)settingsForm.listedCountNumeric.Value;
settings.reqCount = (int)settingsForm.reqCountNumeric.Value;

settings.sellDelay = Convert.ToInt32(sellDelayBox.Text);
settings.reqDelay = Convert.ToInt32(settingsForm.reqDelayBox.Text);
ReqDelay = settings.reqDelay;
Expand Down Expand Up @@ -1646,6 +1658,7 @@ private void scanButton_Click(object sender, EventArgs e)
{
steam_srch.recentInputList[indx].StatId = status.InProcess;
setStatImg(indx, steam_srch.recentInputList[indx].StatId, recentListView);
steam_srch.listedThreadCount = settings.listedCount;
steam_srch.ScanNewListed();
}

Expand Down Expand Up @@ -1783,7 +1796,8 @@ private void startScan(bool all)

if ((isReady) && (!steam_srch.scaninProg))
{
steam_srch.ScanNewListed();
steam_srch.listedThreadCount = settings.listedCount;
steam_srch.ScanNewListed();
}

}
Expand Down
Loading

0 comments on commit bb20255

Please sign in to comment.