Private Sub btnStart_Click
'Start VPN and wait 5 seconds'
Wait For (StartVPN) complete (Finish As Boolean)
CalltestIP_VPN
End Sub
Sub StartVPN As ResumableSub
Dim i As Intent
i.Initialize(i.ACTION_MAIN, "")
i.SetComponent("de.blinkt.openvpn/.LaunchVPN")
i.PutExtra("de.blinkt.openvpn.shortcutProfileName", "VPN_Telecontrollo")
i.PutExtra("de.blinkt.openvpn.AUTOCONNECT", True)
StartActivity(i)
'Here wait 5 seconds
timer1.Initialize("timer1", 1000)
StartTimer(5) ' 5 seconds
t = Max(0, targetTime - DateTime.Now)
Do While t > 0
Sleep(0)
Loop
Return True
End Sub
Sub StartTimer (Seconds As Int)
targetTime = DateTime.Now + Seconds * DateTime.TicksPerSecond
timer1.Enabled = True
End Sub
Sub Timer1_Tick
t = Max(0, targetTime - DateTime.Now)
Dim seconds As Int
seconds = (t Mod DateTime.TicksPerMinute) / DateTime.TicksPerSecond
lblCountDown.Text=$"$2.0{seconds}"$ ' the label show the countdown
If t = 0 Then
timer1.Enabled = False
End If
End Sub