Sep 19, 2010 at 9:07 AM


A couple of questions about this new property.  In the SDK example 'CreateAndDialVpnEntry' you use a boolean flag 'connectionAttemptCompleted' to track if the dialer is still dialing.  Could I just check the IsBusy property instead? Does that have the same meaning?

Also what would be very useful on the RasDialer is an 'IsConnected' property.  As that doesn't exist what is the best way to check this? Check if the connection is included in RasConnection.GetActiveConnections or if I need to do that often would it be better to use a ConnectionWatcher? Or is there another way?

Thanks for this excellent project!




Sep 19, 2010 at 2:43 PM

Hi James,

The IsBusy property does track whether the RasDialer instance is currently dialing a connection, as part of the event-based asynchronous pattern the component implements. The field you were talking about could be taken as an earlier version of the IsBusy property. I'll update the example to use the new property, I need to update them to all use VS 2010 yet anyway.

In regards to your IsConnected property request, use the DialCompletedEventArgs class in the RasDialer.DialCompleted event. It has a Connected property which will indiate the connected state of the last connection attempt. If you dialed two connections with the same RasDialer the IsConnected property would not know which connection it was supposed to track and would need to be reset for each connection attempt even if the previous connection was still connected.

Using any of the RasConnection.GetActiveConnections methods can serve as a test to determine whether your specific connection is active. However, as indicated in the SDK the RasConnection.GetActiveConnections method does not return a connection while it's connecting, it will only return the connection once the connection attempt has completed. If you need to poll whether connection(s) are active, you may want to use a RasConnectionWatcher since it's event driven. There is no polling mechanism in it since Windows notifies the component when connections change, which will save CPU cycles. However, if you do use the component keep in mind Windows will decide when it needs to notify you, which may not be immediate.

- Jeff

Sep 19, 2010 at 3:00 PM

Hi Jeff,

Thanks for the quick and very useful answer.  I had overlooked that the same RasDialer could be used to dial more than one connection, in my simple app that's not an issue so it didn't occur to me.

I think I will use a RasConnection watcher because as you say this seems more efficient than polling RasConnection.GetActiveConnections just to make sure my connection is still alive.

Great stuff, thanks again,



Sep 19, 2010 at 3:01 PM

Glad I could help. Happy coding!