我正在尝试制作解压缩程序,但是当我开始执行解压缩功能时,程序被冻结或出现了一些延迟,但我尝试失去异步,但是却出现了错误:Await要求类型“ Task”具有合适的GetAwaiter方法。 这是我的代码
Private Async Sub PictureBox8_MouseClick(sender As Object, e As MouseEventArgs) Handles PictureBox8.MouseClick
Dim worker As New Task(startUnZip())
worker.Start()
Await worker
MsgBox("Done.")
End Sub
我的startunZip()代码也是:
Public Function startUnZip()
IO.Directory.CreateDirectory(outputFolder)
Dim output As Object = shObj.NameSpace((outputFolder))
Dim input As Object = shObj.NameSpace((inputZip))
output.CopyHere((input.Items), 20)
Return 100
End Function
谢谢。
答案 0 :(得分:0)
首先,打开Option Strict On
,然后解决它所标记的问题,包括指定函数的返回类型。
关于这个问题:
Private Async Sub PictureBox8_MouseClick(sender As Object, e As MouseEventArgs) Handles PictureBox8.MouseClick
Await Task.Run(AddressOf startUnZip)
MsgBox("Done.")
End Sub