问题描述
i有一段代码可以发送和接收请求。
string val = objclient.GetAsync(struri ).Result.RequestMessage.RequestUri.AbsoluteUri.ToString();
但是当我运行这个ia循环大约15 uri'时,需要花费很多时间。
for(int i = 0; i< = 16; i ++)
{
string val = objclient.GetAsync(uri [i])。Result.RequestMessage.RequestUri.AbsoluteUri.ToString();
}
有没有办法优化这段代码。
hi,
i have a written a piece of code which sends and receives request.
string val = objclient.GetAsync(struri).Result.RequestMessage.RequestUri.AbsoluteUri.ToString();
but when i run this i a loop for about 15 uri''s it takes a lot of time.
for(int i =0;i<= 16;i++)
{
string val = objclient.GetAsync(uri[i]).Result.RequestMessage.RequestUri.AbsoluteUri.ToString();
}
Is there any way to optimize this piece of code.
这篇关于如何在c#中使用httpclient获取respose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!