CoachBarker
Well-known member
- Joined
- Jul 26, 2007
- Messages
- 133
- Programming Experience
- 1-3
I can check to see if the VPN is running in my application.
Then on a button click I can verify this
If the VPN is not running I want to set a timer to check every 10 seconds to see if it is still running
Yet it does not anything, can someone look at it and point out the error of my ways. I would like to loop through the timer 5 times and if the VPN is still not running close the application. I know that on
Thanks
CoachBarker
VB.NET:
Public Function VPNRunning() As Boolean
Try
Dim pppAddress() As System.Net.NetworkInformation.NetworkInterface = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
For Each cInterface As System.Net.NetworkInformation.NetworkInterface In pppAddress
If cInterface.NetworkInterfaceType = Net.NetworkInformation.NetworkInterfaceType.Ppp Then
TextBox1.Text = (cInterface.GetIPProperties.UnicastAddresses.Item(0).Address.ToString())
If pppIPAddresses = (cInterface.GetIPProperties.UnicastAddresses.Item(0).Address.ToString().Remove(10, 4)) Then
TextBox2.Text = (cInterface.GetIPProperties.UnicastAddresses.Item(0).Address.ToString().Remove(10, 4))
Return True
End If
End If
Next
Return False
Catch ex As Exception
End Try
End Function
Then on a button click I can verify this
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If VPNRunning() = True Then
Else
If MessageBox.Show("SU VPN is not running right now, Please Log into the VPN?.", "VPN not running", _
MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.OK Then
' Launch the Log In Dialog window
Process.Start("rasphone.exe")
Timer1.Start()
Timer1_Timer()
End If
End If
End Sub
If the VPN is not running I want to set a timer to check every 10 seconds to see if it is still running
VB.NET:
Private Sub Timer1_Timer()
'Code to Run every 10 secs
If VPNRunning() = True Then
' do nothing
Else
Timer1.Enabled = True
Timer1.Interval = 10000
If MessageBox.Show("SU VPN is not running right now, Please Log into the VPN?.", "VPN not running", _
MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.OK Then
End If
End If
End Sub
Yet it does not anything, can someone look at it and point out the error of my ways. I would like to loop through the timer 5 times and if the VPN is still not running close the application. I know that on
VB.NET:
me.close():D
Thanks
CoachBarker