B4J Question Timer on NON-UI apps only run once

adjie

Member
Licensed User
Longtime User
I'm trying to create a looping log using timer. But why the the Timer_Tick never get fired ? Please help. Thanks.
Here is the code :
B4X:
'Non-UI application (console / server application)
#Region  Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Dim Timer1 As Timer
  
End Sub

Sub AppStart (Args() As String)
    Timer1.Initialize("Timer1",2000)
    Timer1.Enabled = True
  
End Sub

Sub Timer1_Tick
    WriteTextWriter
End Sub

Sub WriteTextWriter
    Dim TextWriter1 As  TextWriter
    TextWriter1.Initialize(File.OpenOutput(File.DirApp, "Text.txt", True))
    For i = 1 To 10
        TextWriter1.WriteLine("Note: " & i)
    Next
    TextWriter1.Close
End Sub

*note: sory, the threads name little bit wrong. It shoud be : Timer on NON-UI apps never run (because previously I had writen a log file and I though it from this code, but actualy it's not.)
 
Top