c# - Increase Async HttpClient GetStringAsync speed. Won't make any check difference if I pass different values to check at the same time -
i'm checking on own server if username turns aviable or not. code run in while loop until condition turns true , other code executed.
my problem:
it doesn't matter value store inside int amount
parameter. speed of checks remain same.
could caused defaultconnectionlimit
or similare?
what want do:
i want increase following value:
int amount = int32.parse(bunifucustomlabel11.text);
to run more checks @ same time. @ specific point speed wouldn't increase anymore. let's pass value 100 code executed in same speed when entered 200 example.
functions: check current status of handle/username , return true or false:
private async task checkuntiloneoftheusersisavaliable() { int amount = int32.parse(bunifucustomlabel11.text); await task.whenany(enumerable.range(0, amount).select(i => checkuntiluserisavaliable())); // if aviable run other code.. } private async task checkuntiluserisavaliable() { while (!await isuseravaliable(bunifumetrotextbox3.text) && changeduser == false) { // method_5 increaes label method_5(); await task.delay(1000); } } private async task<bool> isuseravaliable(string handle) { while (true) { using (httpclient client = new httpclient()) { try { string content = await client.getstringasync("http://urlcom/script.php?user=" + handle); return content.contains("no users found"); } catch (webexception ex) { console.writeline(ex.message); } } } }
there limitations to
the number of tasks can run in parallel. not 100, or 200.
the number of connections service or hosted server allows same client.
you can write debug log see how many httpclient
instances actively talking server.
Comments
Post a Comment