WebClient 不支持并发 I/O 操作

广告:阿里云新人专场

System.NotSupportedException: WebClient 不支持并发 I/O 操作。
在 System.Net.WebClient.ClearWebClientState()
在 System.Net.WebClient.DownloadFileAsync(Uri address, String fileName, Object userToken)
在 Readpaper.WebClientDownfile.Downbkfile(String webfile, String& datafile) 位置 E:\aspnet2.0\WebClientDownfile.cs:行号 91

解决:创建多个类

WebClientDownfile wd5 = new WebClientDownfile();
Thread thread5 = new Thread(new ThreadStart(() => wd5.Downbkfile(f5, out d1)));
thread5.Start();
thread5.Join();
thread5.Abort(); //线程启动马上关闭

WebClientDownfile wd6 = new WebClientDownfile();

如:System.Net.WebClient myWebClient1= new System.Net.WebClient();
System.Net.WebClient myWebClient2 = new System.Net.WebClient();

广告:阿里云采购优惠专区

编辑:Admin 时间:2022/5/31 18:21:58 阅览:38   返回    
WebClient
扫描关注53BK报刊官网
扫描关注阅速公司微信