I am using a timer object in vb.net 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