#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private timer As Timer
Private j As HttpJob
Private TIMER_LIMIT As Int = 5
Private REQUEST_LIMIT As Int = 2
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("myLayout")
If Button1.IsInitialized = False Then
Button1.Initialize("Button1")
Activity.AddView(Button1, 10dip,10dip,100dip,100dip)
Button1.Text = "Click"
End If
timer.Initialize("timer", TIMER_LIMIT * DateTime.TicksPerSecond)
LogColor("Timer limit: " & (TIMER_LIMIT * DateTime.TicksPerSecond), Colors.Blue)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Log("+++ Start: " & DateTime.Time(DateTime.Now))
timer.Enabled = True
j.Initialize("", Me)
j.Download("https://www.google.com")
j.GetRequest.Timeout = REQUEST_LIMIT * DateTime.TicksPerSecond
'LogColor("TicksPerSecond: " & DateTime.TicksPerSecond, Colors.Blue)
LogColor("Request limit: " & (REQUEST_LIMIT * DateTime.TicksPerSecond), Colors.Blue)
ProgressDialogShow2("querying...", True)
Wait For (j) JobDone(Job As HttpJob)
Dim isJobSuccess As Boolean = Job.Success
j.Release
If isJobSuccess = False Then
LogColor("Connetion Error: " & CRLF & Job.ErrorMessage, Colors.Red)
End If
Log("is Success? " & isJobSuccess)
ProgressDialogHide
Dim lng2 As Long = DateTime.Now
Log("=== End (JobDone): " & DateTime.Time(lng2))
If timer.Enabled Then
timer.Enabled = False
End If
End Sub
Sub timer_tick
timer.Enabled = False
ProgressDialogHide
Log("~~~ End (Timeout): " & DateTime.Time(DateTime.Now))
If j.IsInitialized Then
j.Release
End If
End Sub