项目启动时就执行异步函数,但只要一提示连接不到服务器就项目卡死了。这个异步执行函数只是一个FTP上传文件,无需返回什么,只是连接不到FTP服务器做个提示,如果FTP服务器能正常连接就没有问题,如不能连接就会卡死。老师帮看下代码那里不对
Dim cmd1 As new SQLCommand
cmd1.CommandText = "Select 值 fr om {设置} Where 类型 = '电话录音'"
Dim Values1 = cmd1.ExecuteValues
Dim strg As String
If Values1.count > 0 Then
strg = Values1("值")
End If
For Each file As String In FileSys.GetFiles(strg)
If file.EndsWith(".wav") Then
Dim s As Integer = file.LastIndexOf("\")
s = s + 1
Dim abfile As String = file.SubString(s)
Dim cmd As new SQLCommand
cmd.CommandText = "Select 参数,参数2,参数3,参数4 fr om {本地设置} Where 名称 = '录音上传FTP服务器'"
Dim Values = cmd.ExecuteValues
Dim ftp1 As New FtpClient
If Values.Count > 0 Then
ftp1.Host = Values("参数")
ftp1.Account = Values("参数2")
ftp1.Password = values("参数3")
ftp1.Port = values("参数4")
If ftp1.Connect = True Then
If ftp1.FileExists("\录音\" & abfile & "") = False Then
ftp1.Upload(file,"\录音\" & abfile & "")
ftp1.Close
End If
Else
PopMessage("FTP备份服务器无法连接,请检查网络","错误",PopIconEnum.Error,5)
End If
End If
End If
Next