gpt4 book ai didi

silverlight - 随后启动两个 WebClient.UploadStringAsync 调用

转载 作者:可可西里 更新时间:2023-11-01 16:04:52 25 4
gpt4 key购买 nike

当两次调用 WebClient.UploadStringAsync 时,没有等待 WebClient.UploadStringCompleted 事件,抛出以下异常:

“WebClient不支持并发I/O操作”

显然,这是不支持的。

之所以想要发起多个 HTTP POST 请求而不必等待之前的响应到达,是因为性能;我想避免往返延迟。是否有解决此限制的方法?

最佳答案

您需要使用多个 WebClient 实例。

 var wc1 = new WebClient();
wc1.UploadStringCompleted += (s, args) => {
// do stuff when first upload completes
}
wc1.UploadString(uri1,str1);

var wc2 = new WebClient();
wc2.UploadStringCompleted += (s, args) => {
// do stuff when second upload completes
// might happen before first has completed
}
wc2.UploadString(uri2,str2);

关于silverlight - 随后启动两个 WebClient.UploadStringAsync 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2085490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com