这个问题太离谱了。我提交它是希望有人可能以前看过它并且知道修复。
环境 VB6、SQL 2005、Citrix XenApp 6.5。此行为仅在从 Citrix 客户端运行时出现。
上下文:
Main .bas 模块加载并在 Main sub 中调用 SQL server (2005) 使用 ADO 记录集加载数据。从控制台运行时,应用程序会在 1 或 2 秒内加载并显示。当从 Citrix 客户端调用时,它会减慢至少 30 倍。但是,如果我们放置一个 MsgBox
IE
MsgBox "测试消息..."
在 Main sub 的代码中,它在 1 到 2 秒内加载,就像从控制台加载一样。MsgBox 必须在加载用作应用程序视觉背景的 MDI 表单之后放置。如果在加载 MDI 之前放置,则不能解决问题。
通过将调试消息放在 MDI 表单的标题中,我们检测到遍历记录集所花费的时间是所有时间都被添加进去的地方。
问题是 MsgBox 语句如何影响记录集的访问速度。听起来很奇怪,但是有了 MsgBox 语句:快,没有它:非常慢。
下面是 Sub Main 的简化版本,其中显示了神奇的 MsgBox。
****************************************************************
*
****************************************************************
Sub Main()
On Error GoTo errHandler
'CSR 527
If Not ReadIniFiles Then
MsgBox "Error reading ini files...contact systems.", vbExclamation
End
End If
g_SecurityInClause = "YES"
If Not SetSecurity Then
MsgBox "Unable to acquire your authorization credentials. Exiting..."
Exit Sub
End If
Set cn = New Connection
With cn
' .ConnectionTimeout = 30
.ConnectionString = CONNECTION_STRING
.Open 'Options:=adAsyncConnect
End With
App.HelpFile = App.path & "\xx.chm"
g_bExiting = False
frmMain.MousePointer = vbHourglass
DoEvents
frmMain.Show
MsgBox "test" <== PLACING THIS MSGBOX HERE SPEEDS UP APP BY A FACTOR OF AT LEAST 30
IF IT IS ABOVE frmMain.Show IT HAS NO EFFECT
'assign connection string and record source to ado controls
'PLOG 74
Load frmA
frmA.Adodc1.ConnectionString = CONNECTION_STRING
frmA.Adodc2.ConnectionString = CONNECTION_STRING
frmA.Adodc3.ConnectionString = CONNECTION_STRING
'timeouts for Phoenix
frmA.Adodc1.CommandTimeout = 300
frmA.Adodc2.CommandTimeout = 500
frmA.Adodc3.CommandTimeout = 500
frmA.Adodc1.RecordSource = "select some stuff"
frmA.Adodc2.RecordSource = "select some stuff"
frmA.Adodc3.RecordSource = "select some stuff"
frmA.Adodc1.Refresh
frmA.Adodc2.Refresh
frmA.Adodc3.Refresh
LoadMinorCodes
DetermineDeleteAccess
LoadStates
frmMain.MousePointer = vbNormal
frmStartBoard.Show
Exit Sub
errHandler:
MsgBox Err.Number & " " & Err.Description & " Main"
End Sub