AddTapi.NET Developer's Manual
Disconnect Method
NamespacesTraysoft.AddTapiTapiCallDisconnect()()()
Disconnects the call.
Declaration Syntax
C#Visual BasicVisual C++
public void Disconnect()
Public Sub Disconnect
public:
void Disconnect()
Remarks

Disconnect is an asynchronous operation. Disconnect method requests disconnect and returns immediately. The call is disconnected by the telephony hardware within a few second after the Disconnect call. AddTapi.NET fires CallDisconnected event when the call is actually disconnected.

If the call is in the connected state (Connected), this method drops the connection and releases the line (equivalent to hanging up the phone). If the call is in the dialing state (Dialing), this method aborts the dialing and releases the line.

The application should always call Disconnect before returning from the TapiCallHandler method if the call is no longer needed and should be disconnected. If Disconnect is not called the line will not be released and will not be available to handle future calls. The best way to ensure that the Disconnect is called is to put it into the finally block. Please refer to the following code snapshot and AddTapi.NET samples for details.
Examples
The following code shows how to use Disconnect method in the TapiCallHandler.

C#

            TapiApp.Initialize("MyApp");
            TapiLine line = TapiApp.Lines[0];
            line.Open(true, CallHandler);
            line.RingsToAnswer = 1;
            ...
            
            // This method will be called when incoming call is answered
            private void CallHandler(TapiCall call)
            {
                try
                {
                    call.Play("message.wav");
                    call.WaitUntilDone(60);
                }
                catch (TapiDisconnectException)
                {
                    // Remote party hung up
                }
                catch (Exception exc)
                {
                    // An error occurred
                }
                finally
                {
                    // Disconnect the call to clear up the line
                    call.Disconnect();
                }
            }
            

VB.NET

            TapiApp.Initialize("MyApp")
            Dim objLine As TapiLine
            objLine = TapiApp.Lines(0)
            objLine.Open(True, AddressOf CallHandler)
            objLine.RingsToAnswer = 1;
            ...
            
            ' This method will be called when incoming call is answered
            Private Sub CallHandler(ByVal objCall As TapiCall)
                Try
                    objCall.Play("message.wav")
                    objCall.WaitUntilDone(60)
                Catch exc As TapiDisconnectException
                    ' Remote party hung up
                Catch exc As Exception
                    ' An error occurred
                Finally
                    ' Disconnect the call to clear up the line
                    objCall.Disconnect()
                End Try
            End Sub
            
See Also

Assembly: Traysoft.AddTapi (Module: Traysoft.AddTapi)