Hello
I think I'm losing it. I cannot understand what's wrong, but I'm pretty sure it's my lack of fully understanding the MessageLoop in non-ui applications.
I have this code (simplified)
What I expect: The code runs, newClass objects are added to the Classes list.
After the GetClasses sub is run, I simply print the names of the classes in a for each loop.
But what happens:
The for each loop is never reached, the newClass objects are succesfully added in the Classes list. I can see that with the debugger.
If I set a breakpoint at line 15, the debugger never shows it reaches that line.
What am I doing wrong here?
Thanks!
I think I'm losing it. I cannot understand what's wrong, but I'm pretty sure it's my lack of fully understanding the MessageLoop in non-ui applications.
I have this code (simplified)
Broken code:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Dim Classes As List
End Sub
Sub AppStart (Args() As String)
Classes.Initialize
GetClasses
StartMessageLoop
For Each c As SmartschoolClass In Classes
Log(c.Name)
Next
StopMessageLoop
End Sub
Sub GetClasses()
Dim job As HttpJob
job.Initialize("", Me)
''Here I prep the job
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
Dim json As JSONParser = ExtractJsonFromSmartschoolResponse(job.GetString)
Dim root As List = json.NextArray
For Each colroot As Map In root
newClass.Initialize(colroot.Get("name"), colroot.Get("code"))
Classes.Add(newClass)
Next
End If
End Sub
What I expect: The code runs, newClass objects are added to the Classes list.
After the GetClasses sub is run, I simply print the names of the classes in a for each loop.
But what happens:
The for each loop is never reached, the newClass objects are succesfully added in the Classes list. I can see that with the debugger.
If I set a breakpoint at line 15, the debugger never shows it reaches that line.
What am I doing wrong here?
Thanks!