Today while working on one of the requirement my LS agent thrown the warning saying "In order to do multiple transactions simultaneously,you can't use the same db handle".But, Agent execution doesn't effected.I was curious to know why it has happened, I started my agent again to reproduce the warning.I noticed, I haven't disable the view autoupdate property to false, Could be the reason ? Still I don't give assurance to myself ,What went wrong.
Since my code was taking two different database handle , I suspect delay in releasing first database handle might cause the problem.But who knows ?????
But, Such situation can be avoided if its coming frequently with complex code.Here is the possible solution.
1- Disabled view autoupdate property.
2-
In the view's (Globals) section:
Option Public
Use "libSendKeys"
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (Byval hwnd As Long, Byval lpString As String, Byval cch As Long) As Long
Dim nt As NotesTimer
Dim lHwnd As Long
Dim lCurHwnd As Long
Dim sText As String * 255
Sub handler(nt As NotesTimer)
Dim sCurText As String * 255
Dim i As Integer
lCurHwnd = GetForegroundWindow
If lCurHwnd <> lHwnd Then Exit Sub
i= GetWindowText(lHwnd, Byval sCurText, 255)
sCurText= Trim(Left$(sCurText, i))
If sText<>sCurText Then Exit Sub
Print Now
Call PushKeys("{F9}")
End Sub
In the view's (View) section:
Sub Postopen(Source As Notesuiview)
Dim i As Integer
lHwnd = GetForegroundWindow
i= GetWindowText(lHwnd, Byval sText, 255)
sText= Trim(Left$(sText, i))
Print "ActiveWindow: " + sText
Set nt= New NotesTimer(10)
On Event Alarm From nt Call handler
nt.Enabled= True
Print "Enabled"
End Sub