Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two requests from different threads with different urls in same httpclient instance

Tags:

c#

httpclient

I make two different 'GET' requests from two different threads at the same time. Will i have any conflicts if i will try to send at the same time but with different urls?

 static HttpClient client = new HttpClient();

 private void Thread1()
 {
   var result= await client.GetAsync("http://URL1");
 }

 private void Thread2()
 {
   var result= await client.GetAsync("http://URL2");
 }

Methods Thread1 and Thread2 will run at the same time. Will i have any problem? Or httpclient will handle both requests fine?

like image 389
Giorgos Papadopoulos Avatar asked Jul 18 '26 00:07

Giorgos Papadopoulos


1 Answers

It'll work fine, just like the docs say it will.

like image 164
Stephen Cleary Avatar answered Jul 19 '26 14:07

Stephen Cleary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!