Dim cn() As String = {"OA","ksg"}
Dim st As Date = Date.Now
'要测试耗时的代码
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1")
Dim id As Integer = tab.TabPages.Count
For Each c As String In cn
Dim lst As List(Of String) = Conne ctions(c).GetTableNames
If Forms("数据加载提醒").Opened = False Then Forms("数据加载提醒").Open
For i As Integer = 0 To lst.Count - 1
If i = 2 Then Exit Sub
tab.TabPages.Add(c & lst(i), lst(i))
Functions.AsyncExecute("MySaveExcel",c,lst(i),id + i) ‘异步函数出问题。
' Functions.Execute("MySaveExcel",c,lst(i),id + i) '常规调用函数没有问题,
Next
Next
If Forms("数据加载提醒").Opened = True Then Forms("数据加载提醒").Close
MessageBox.Show("数据备份完成!耗时: " & (Date.Now - st).TotalSeconds & "秒")
e.Form.Close
以下是内部函数!
Dim tab As WinForm.TabControl = Forms("管理调试").Controls("TabControl1")
Dim c As String = args(0)
Dim lstr As String = args(1)
Dim id As Integer = args(2)
Dim tbl As WinForm.Table
tbl = Forms("管理调试").CreateSQLTable(c & lstr,"sel ect * from {" & lstr & "} " ,c)
'tbl.Dock = 5
tab.Tabpages(id).AddControl(tbl)
Tables(Forms("管理调试").Name & "_" & tbl.Name).SaveExcel("D:" & Format(Functions.Execute("返回服务器日期"),"yyyy_MM_d") & "\" & c & "\" & lstr & ".xls" ,lstr)
[此贴子已经被作者于2020/8/11 11:17:43编辑过]