Jul 29, 2011 04:28 AM
(This post was last modified: Jul 29, 2011 04:29 AM by CaptainBri.)
I just wrote a Proxy Checker to improve my knowledge on multi-threading and invoking while on another thread, and this is what I made of it ^^
![[Image: fqogg.png]](https://i.imgur.com/fqogg.png)
When you check the proxies
![[Image: iojbV.png]](https://i.imgur.com/iojbV.png)
End result
![[Image: 9EQpZ.png]](https://i.imgur.com/9EQpZ.png)
Pretty basic stuff, you can enter the timeout in the textbox and it will rule out all proxies that have a timeout for longer than that time (= not working or way to slow)
Up to you to advance it, such as resizing the app with anchors (easy ^^), copy to clipboard, scrollbars and stuff.
The source in plain text:
And if you'd like the project here it is: http://leetcoders.org/forum/showthread.php?tid=128 (Scroll to the bottom)
Have fun with it :)
CaptainBri
![[Image: fqogg.png]](https://i.imgur.com/fqogg.png)
When you check the proxies
![[Image: iojbV.png]](https://i.imgur.com/iojbV.png)
End result
![[Image: 9EQpZ.png]](https://i.imgur.com/9EQpZ.png)
Pretty basic stuff, you can enter the timeout in the textbox and it will rule out all proxies that have a timeout for longer than that time (= not working or way to slow)
Up to you to advance it, such as resizing the app with anchors (easy ^^), copy to clipboard, scrollbars and stuff.
The source in plain text:
PHP Code
<?php
int Working = 0;
int Broken = 0;
int Timeout = 10000;
private void btnCheck_Click(object sender, EventArgs e)
{
Working = 0;
Broken = 0;
Timeout = Convert.ToInt32(txtTimeout.Text);
string[] Lines = txtInputProxies.Lines;
prgProgress.Maximum = Lines.Length;
for (int i = 0; i < Lines.Length; i++)
{
new Thread(
delegate(object o)
{
try
{
string[] Proxy = ((string)o).Split(':');
WebRequest req = WebRequest.Create("http://google.nl");
req.Proxy = new WebProxy(Proxy[0], Convert.ToInt32(Proxy[1]));
req.Timeout = Timeout;
req.GetResponse();
UpdateStatus(true, string.Join(":", Proxy));
}
catch
{
UpdateStatus(false, "");
}
}
).Start(Lines[i]);
}
}
private void UpdateStatus(bool goodProxy, string Proxy)
{
Invoke(new MethodInvoker(
delegate()
{
prgProgress.Value++;
if (goodProxy)
{
txtWorkingProxies.Text += Proxy + Environment.NewLine;
lblWorking.Text = "Working: " + (++Working).ToString();
}
else
{
lblBroken.Text = "Broken: " + (++Broken).ToString();
}
lblTotal.Text = "Total: " + (Broken + Working).ToString();
}));
}
And if you'd like the project here it is: http://leetcoders.org/forum/showthread.php?tid=128 (Scroll to the bottom)
Have fun with it :)
CaptainBri


