This project is read-only.

Am I connected?

Sep 10, 2009 at 9:04 AM

Hi Jeff!

How is the best way to know if I'm connected throw my VPN connection?

I am using:


myDialer.StateChanged += new EventHandler<StateChangedEventArgs>(dialer_StateChanged);


And on handler:

void dialer_StateChanged(object sender, StateChangedEventArgs e)
            RasPhoneBook rpb = new RasPhoneBook();
            string path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers);

            for (int i = 0; i < rpb.Entries.Count; i++)
} }

I don't know exactly how can I know if I am connected....


Sep 10, 2009 at 3:46 PM
Edited Sep 10, 2009 at 3:50 PM

If you're dialing a connection asynchronously (which it looks like you are) use the DialCompleted event and check the Connected property on the DialCompletedEventArgs class passed to the event. That was a new feature in 1.1. :)

Edit: If you're simply wanting to know what connections are active on the machine, check the dialer.GetActiveConnections() method. It'll return a collection of RasConnection objects active on the machine. NOTE: This method is moving to a static method on RasConnectionWatcher in 1.2.