Foxtable(狐表)用户栏目专家坐堂 → [求助]异步函数请教


  共有2339人关注过本帖平板打印复制链接

主题:[求助]异步函数请教

帅哥哟,离线,有人找我吗?
2900819580
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1327 积分:9648 威望:0 精华:0 注册:2015/6/30 8:46:00
[求助]异步函数请教  发帖心情 Post By:2020/8/11 11:17:00 [只看该作者]

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编辑过]

 回到顶部