Anonymous_User Absent Member.
Absent Member.

timer objects in

I am using a timer object in to poll a given directory for an
input file that will then be used to modify my gw system. (re-writing
the api gateway) I have found that I am able to connect and affect gw
when I run a single pass of my code, however, when I try to connect to
gw from the callback of a timer object it dies with no error of any
sort. Has anyone sucessfully used the gwadminapi from a timer object?
Does the multi-threaded nature of a timer object confuse the adminapi?
Below are some code snips so you can see what is going on.


Sub Main()
WriteToLog("GW XML Agent Started")

Dim test As Integer = 2
' solo test
If test = 1 Then
Dim t1, t2 As Date
t1 = Now
t2 = Now
Console.WriteLine(t2.Subtract(t1)) 'how long did it take?
End If
' timer test
If test = 2 Then
Dim s As New TimerExampleState
' Create the delegate that invokes methods for the timer.
Dim timerDelegate As New TimerCallback(AddressOf CheckInput)
'Dim timerDelegate As New TimerCallback(AddressOf TestCallback)
' Create a timer that waits one second, then invokes every second.
Dim timer As New Timer(timerDelegate, s, 1000, 1000)
' Keep a handle to the timer, so it can be disposed.
s.tmr = timer
End If

End Sub

Sub CheckInput(ByVal state As Object)
Dim di As New DirectoryInfo(gsInputDir)
Dim fi As FileInfo() = di.GetFiles("*.xml")
If fi.Length > 0 Then
Dim oGWConnect As Boolean = ConnectToGW()
Dim fiTemp As FileInfo
For Each fiTemp In fi
ProcessXMLFile(gsInputDir + "/" + fiTemp.Name)
Next fiTemp
End If
End Sub

Function ConnectToGW() As Boolean
If File.Exists(String.Concat(gsWPDomain, "\wpdomain.db")) Then
goGWSystem = CreateObject("NovellGroupWareAdmin") ' dies here
when originating from timer object
Console.WriteLine("after CreateObject NovellGroupWareAdmin")
If goGWSystem Is Nothing Then
LogError(String.Concat("Could not connect to GW System:",
Return False
End If
LogError(String.Concat("Could not find wpdomain.db file:",
Return False
End If
Return True
End Function
Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.