This project is read-only.

How create a dialup connection that dont keep alive when my program close anormal?

Dec 24, 2009 at 4:17 PM

Hello, I want to make a program that establish a dialup connection, and count the connection duration, and when it arrive to an especify time it close the connection. so far all normal but, what happen if the user close the process of the program, then the connection remain but the program cant control the connection because it is close, Have anyone an idea for avoid that ???? Thank

note: I am new in this community, I very glad for that, this is a very professional and nice community.

please feel free to send me and SMS to 5353387675

Dec 26, 2009 at 4:02 AM

Have the application terminate the connection when it's closing. Keep in mind if an error occurs while the application is terminating the connection may be left in an inconsistent state and require a reboot to fix it. You'll need to handle any error trapping during the closing process.

using DotRas;

foreach (RasConnection connection in this.rasDialer1.GetActiveConnections())
{
    if (connection.EntryName == "VPN Connection")
    {
        connection.HangUp();
    }
}

That's the basic syntax for disconnecting an active connection.

Dec 28, 2009 at 2:57 PM

ok, but can i be sure that the "closing" event happens even when the user close the application from the task mannager ??

Dec 28, 2009 at 5:08 PM

I think you might be confusing exactly what this project does. It does not dial anything itself, it is a wrapper which hooks into the Win32 APIs exposed by Microsoft to manage network connections. That's the reason why when your application closes the connection remains open. A connection is never tied to an application since the operating system can always dial the connection itself.

When an application is terminated, the process is ended immediately. I personally do not know if .NET has any events that may fire when the process is being terminated, but I vaguely recall an event containing a reason why the form is being closed somewhere.

I don't have time to help you develop your application, I have way too much work to do right now as it is. The scope of this projects ends at the project, it's your responsibility to develop a functional application which uses the project if you choose to use it at all.

Dec 28, 2009 at 5:53 PM

I  understand what DotRas does, actully I already fineshed my proyect, thanks to DotRas it really help me a lot. I just ask this because I think maybe exist a way, but I think exactly like you. thank you very much for offer your help.

Jan 7, 2010 at 6:17 PM

Catch the FormClosing or FormClosed events on a base form  works in a Windows Forms app