我正在创建一个源forge -latest文件下载器,当我尝试获取链接时,表单会冻结一段时间(10-15秒)
这是我的代码:
public IHttpActionResult GetInteger() {
// Ok is a convenience method for returning a 200 Ok response
return Ok(new {
value = 1
});
}
我必须做些什么来阻止这种冻结?
答案 0 :(得分:0)
我通过使用背景工作代码解决了这个问题:
Private Sub SourceForgeDownload_DoWork(sender As Object, e As DoWorkEventArgs) Handles SourceForgeDownload.DoWork
SourceForgeDirectLink = SourceForgeGetDirectUri("https://sourceforge.net/projects/openofficeorg.mirror/files/latest/download")
If CheckBox1.Checked = True Then
Dim wc As New WebClient()
AddHandler wc.DownloadProgressChanged, AddressOf wc_Changed
AddHandler wc.DownloadFileCompleted, AddressOf wc_Completed
wc.DownloadFileAsync(New Uri(SourceForgeDirectLink), My.Computer.FileSystem.CurrentDirectory + "filename.exe")
End If
End Sub