Click or drag to resize

ChannelResourceDispose Method

This method forces a dispose of the Channel Resource object. Always do this in hang up handling to ensure clean up.

Namespace:  VoiceElements.Client
Assembly:  VoiceElementsClient (in VoiceElementsClient.dll) Version:
protected internal override void Dispose(
	bool disposing


Type: SystemBoolean
This parameter specifies if managed resources should be disposed as well. True will dispose managed resources, false will not. It is recommended you use true here unless you have a specific reason to maintain some managed resources.
Generally the .NET garbage collector will handle this, but it is always a good idea to put this method in your call wrap up code on hang up. To ensure this is executed, put it in a finally block as shown in the example below.

Outbound Application Warning: Stop Dial Needs to be Called if Channels Could be Dialing

The dispose method on a channel will not stop a dialing call. Make sure you call StopDial first to make sure channels get properly disposed if your channels could be dialing.

The example below shows a typical New Inbound Call Event skeleton with the Dispose of the Channel Resource object in the finally block as highly recommended. Also note that right before the dispose you should always call the Disconnect Method.
static void s_TelephonyServer_NewCall(object sender, VoiceElements.Client.NewCallEventArgs e)
    Log.Write("NewCall Arrival! DNIS: {0}  ANI: {1}  Caller ID Name: {2}", e.ChannelResource.Dnis, e.ChannelResource.Ani, e.ChannelResource.CallerIdName);

    // Handle The New Call Here
    // You should acutally create a class to handle this call.  See the Sampler application for how to do this.

    // You can subscribe to get the disconnected event.
    e.ChannelResource.Disconnected += new Disconnected(ChannelResource_Disconnected);


  catch (HangupException)
    Log.Write("The Caller Hung up.");
  catch (Exception ex)
    Log.WriteException(ex, "New Call Event Exception");
    // Unsubscribe the event.
    e.ChannelResource.Disconnected -= new Disconnected(ChannelResource_Disconnected);
    // Hangup

    // Always force the dispose of the channel object.

    Log.Write("Call complete.");

See Also