gpt4 book ai didi

vb.net - 图片下载完成后启用按钮。

转载 作者:行者123 更新时间:2023-12-01 19:37:30 25 4
gpt4 key购买 nike

好的,我在 Visual Basic 中遇到问题,我得到了下载图片的代码。

WC.DownloadFileAsync(New Uri("picturelinkhere"), "c:\myfile.jpg")

之后我有一个使下载按钮变灰的代码

Button1.Enabled = False

问题是我想等待文件下载完成然后再次启用 Button1

我尝试过使用

System.Threading.Thread.Sleep(1000)

但问题是它使得程序中的进度条非常滞后。

有什么想法吗?

最佳答案

根据MSDN :

To receive notification when the file is available, add an event handler to the DownloadFileCompleted event.

例如,您可以这样做:

AddHandler WC.DownloadFileCompleted, AddressOf DownloadFileCompleted

然后在事件处理程序方法中重新启用按钮,如下所示:

Private Sub DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs)
Button1.Enabled = True
End Sub

关于vb.net - 图片下载完成后启用按钮。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16419554/

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