跟踪 HTTPWebRequest 的进度
如何跟踪 HTTPWebRequest
的上传进度?当我分散 Debug.WriteLines()
来跟踪代码的哪些部分花费了最长的时间时,我发现花费最长时间的函数是
var res = req.GetResponse();
我可以使用 BeginGetResponse()
但我仍然无法跟踪进度?我从各种文章中读到,在写入请求流时我应该跟踪进度,但我认为这发生在本地,因此几乎是瞬时的。
对于 WebClient
,有 webClient.UploadProgressChanged
允许我跟踪进度,但我想我不能使用 MultipartFormData
吗?而且我不能一次进行多个上传,但这并不是什么大问题,在我的简单应用程序中,
我如何使用 HTTPWebRequest
跟踪上传/下载进度?
How can I track upload progress of HTTPWebRequest
? When I scattered Debug.WriteLines()
to track which parts of my code takes the longest time, i found out the function that took the longest time is
var res = req.GetResponse();
I could use BeginGetResponse()
but I have no way of tracking progress still? I read from various articles that I should track progress when writing to request stream, but I suppose that happens locally and thus is nearly instantaneous
With WebClient
, there is webClient.UploadProgressChanged
that allows me to track progress, but I think I can't use MultipartFormData
with that? And I can't have multiple uploads at once, not a really big deal tho, in my simple app
How can I then track upload/download progress with HTTPWebRequest
then?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在
webclient
类you have events for tracking thins in the
webclient
class