这里是我的代码如何同时运行多个Web客户端?
try
{
for (int i = 0; i < RichTextbox2.Lines.Length; i++)
{
var length = urlwebapi.Lines.Length;
{
WebClient f = new WebClient();
dynamic read = f.DownloadString(urlwebapi.Lines[(i % length)] + RichTextbox2.Lines[i]);
JObject o = JObject.Parse(read);
}
}
}
catch (WebException e)
{
MessageBox.Show(e.Message);
}
MessageBox.Show("done");
样品urlwebapi
http://example1.com/api.php?ex=
http://example2.com/api.php?ex=
http://example3.com/api.php?ex=
http://example4.com/api.php?ex=
http://example5.com/api.php?ex=
的代码只能在同一时间在urlwebapi运行一个。怎么办时,在同一时间
看看[DownloadStringAsync](https://msdn.microsoft.com/de-de/library/system.net.webclient.downloadstringasync(v = vs.110).aspx)。这应该可以帮助你处理多个请求。 –