避免并发Webclient IO线程的条件语句
我正在使用网络客户端从网络服务器下载媒体文件并将其保存到独立存储中。
如果您单击一个按钮,它会启动下载并保存到 Iso 存储进程,但如果您在下载文件时单击该按钮,它会尝试创建一个并发 IO 线程来再次下载,并且 webclient 错误不允许并发 IO 线程。
我想编写一个条件 if 语句来检查是否已经有一个 IO 线程正在使用,但我不确定如何执行此操作。
任何帮助将不胜感激。
I am using a webclient to download a media file from my web server and save to isolated storage.
If you click a button it starts the download and save to Iso store process, but if you click the button while the file is downloading it tries to create a concurrent IO thread to download again and errors with webclient does not allow concurrent IO threads.
I want to write a conditional if statement to check if there is already a IO thread in being used but I'm not sure how I would do this.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能只使用布尔值来查看是否已经开始下载吗?无论哪种方式,听起来最好在开始下载后实际禁用 UI 中的按钮,并在下载完成或失败后再次启用它。
您的 UI 应与用户在给定时间能够执行的操作保持一致 - 让他们尝试某些操作,然后让他们失败,这听起来像是令人沮丧的用户体验。
Can't you just use a boolean to see if you started the download already? Either way it sounds like it would be better to actually disable the button in the UI after you start a download, and enable it again once it finishes or fails.
Your UI should be consistent with what users have the ability to do at a given time - letting them try something and then make them fail sounds like a frustrating user experience.