hello guys,
i have a question about the "stopwatches", i need to create 100 thousand counters every 10 seconds to be activated asynchronously, if i use the algorithm below will i have any future problems? or do I need to use the "Threading" library?
For each connection I need to initialize an asynchronous Timer .
algorithm :
my fear is that there will be some inconsistency in the timers ...
is it stable?
i have a question about the "stopwatches", i need to create 100 thousand counters every 10 seconds to be activated asynchronously, if i use the algorithm below will i have any future problems? or do I need to use the "Threading" library?
For each connection I need to initialize an asynchronous Timer .
algorithm :
B4X:
Sub Process_Globals
Public srvr As Server
Private threading As Thread 'Need i use this ?
Type TStopWatch (Identificador As String, cronometro As Timer)
Dim stopwatch(99) As TStopWatch
End Sub
Sub AppStart (Args() As String)
srvr.Initialize("srvr")
srvr.Port = 80
srvr.AddWebSocket("/appserver", "AppServer")
srvr.AddHandler("/teste", "testes", False)
DB.Initialize
DB.Sync
ServerManager.Initialize
srvr.Start
Log("Server Running on Port [80].")
Log("AppServer Initialized on Port [80/appserver].")
Log("JdbcConnectionPool Inintialized on [localhost:3306]")
For i = 0 To stopwatch.Length-1
stopwatch(i).Initialize
stopwatch(i).Identificador = "identificador = "&i
stopwatch(i).cronometro.Initialize("cronometro",1000)
stopwatch(i).cronometro.Enabled = True
Next
StartMessageLoop
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Log("Error = "&Error)
Log("StackTrace = "&StackTrace)
Return True
End Sub
Sub cronometro_Tick
'Log("sender = "&Sender)
For i = 0 To stopwatch.Length-1
If (stopwatch(i).cronometro = Sender) Then
Log(stopwatch(i).Identificador & " # at " &DateTime.Time(DateTime.Now))
Exit
End If
Next
End Sub
my fear is that there will be some inconsistency in the timers ...
is it stable?