B4J Question Timer on NON-UI apps only run once

Discussion in 'B4J Questions' started by adjie, Jan 18, 2015.

  1. adjie

    adjie Member Licensed 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 :
    Code:
    '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.)
     
  2. billzhan

    billzhan Active Member Licensed User

    Code:
    Sub AppStart (Args() AsString)
     Timer1.Initialize(
    "Timer1",2000)
     Timer1.Enabled = 
    True

    StartMessageLoop  
    'for non-ui apps
     
    End Sub
     
    adjie and Erel like this.
  3. adjie

    adjie Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice