Well below is my code but doesnt seems to work.
public async Task PerformStartChecking(int Bots, List<Proxy> ProxyCollection)
{
var semaphore = new SemaphoreSlim(Bots);
foreach (var proxy in ProxyCollection)
{
await semaphore.WaitAsync();
_ = Task.Run(async () =>
{
try
{
var handler = new HttpClientHandler
{
Proxy = new WebProxy($"http://{proxy.HostIP}:{proxy.Port}"),
UseProxy = true
};
using (var client = new HttpClient(handler))
{
var response = await client.GetAsync("http://www.google.com");
if (response.IsSuccessStatusCode)
{
MessageBox.Show("Good");
}
else
{
MessageBox.Show("Error");
}
}
}
catch (Exception ex)
{
MessageBox.Show($"{ex}");
}
finally
{
semaphore.Release();
}
});
}
}
Ok i dont know why it doesnt work but i got an exception saying this ( i think its a timeout error ) —>;
System.Threading.Tasks.TaskCanceledException: The request was
canceled due to the configured HttpClient.Timeout of 100 seconds
elapsing.
— > System.TimeoutException: The operation was canceled.
— > System.Threading.Tasks.TaskCanceledException: The operation
was canceled.
— > System.IO.IOException: Unable to read data from the transport
connection: The I/O operation has been aborted because of either a
thread exit or an application request ..
— > System.Net.Sockets.SocketException (995): The I/O operation has
been aborted because of either a thread exit or an application request.
— End of inner exception stack trace —
at
System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowExcep
tion(SocketError error, CancellationToken cancellationToken)
at
System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Thre
ading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16
token)
at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async)
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage
request, Boolean async, CancellationToken cancellationToken)
— End of inner exception stack trace —
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage
request, Boolean async, CancellationToken cancellationToken)
at
System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRe
tryAsync(HttpRequestMessage request, Boolean async, Boolean
doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage
request, Boolean async, CancellationToken cancellationToken)
at
System.Net.Http.HttpClient .< SendAsync>g_Core|83_0(HttpRequestMes
sage request, HttpCompletionOption completionOption,
CancellationTokenSource cts, Boolean disposeCts,
CancellationTokenSource pendingRequestsCts, CancellationToken
originalCancellationToken)
— End of inner exception stack trace —
— End of inner exception stack trace —
at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean
telemetryStarted, HttpResponseMessage response,
CancellationTokenSource cts, CancellationToken cancellationToken,
CancellationTokenSource pendingRequestsCts)
at
System.Net.Http.HttpClient .< SendAsync>g_Core|83_0(HttpRequestMes
sage request, HttpCompletionOption completionOption,
CancellationTokenSource cts, Boolean disposeCts,
CancellationTokenSource pendingRequestsCts, CancellationToken
originalCancellationToken)
at