I am facing quite a struggle, I want to iterate over a list using Parallel.Foreach
.
So picture this
static List<string> proxyList = new List<string>();
static List<string> websiteList = new List<string>();
Each list is looking something like this
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
And the website list
https://google.com
https://spotify.com
https://duckduckgo.com
https://amazon.com
I want to achieve something like this but I have no idea how, no matter how I twist and turn I cant seem to find any logic.
Foreach(var proxy in proxyList)
{
If(proxyIsAlive)
//Try to connect to the first website in the website list
else
//Try the next proxy until I get a working one
//and then try to connect to the most recent one
}
}
The issue I am facing is that I have to idea how to access the websites in the website list, I want to connect to
EDIT: this is what my logic looks like so far
private static void Connect()
{
string tproxy = "";
int port;
foreach (var website in websiteList)
{
foreach (var proxy in proxyList)
{
var proxySplit = proxy.Split(':');
tproxy = proxySplit[0];
port = Convert.ToInt32(proxySplit[1]);
//if(ProxyIsAlive)
}
//Use that proxy down here to connect
}
}
I only want to move out of the proxy foreach IF ProxyIsAlive returns true