|
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: 8.6.1.1
Syntax protected internal override void Dispose(
bool disposing
)
Protected Friend Overrides Sub Dispose (
disposing As Boolean
)
protected public:
virtual void Dispose(
bool disposing
) override
abstract Dispose :
disposing : bool -> unit
override Dispose :
disposing : bool -> unit
Parameters
- 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.
Remarks
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.
Examples
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)
{
try
{
Log.Write("NewCall Arrival! DNIS: {0} ANI: {1} Caller ID Name: {2}", e.ChannelResource.Dnis, e.ChannelResource.Ani, e.ChannelResource.CallerIdName);
e.ChannelResource.Disconnected += new Disconnected(ChannelResource_Disconnected);
Log.Write("Answering...");
e.ChannelResource.Answer();
}
catch (HangupException)
{
Log.Write("The Caller Hung up.");
}
catch (Exception ex)
{
Log.WriteException(ex, "New Call Event Exception");
}
finally
{
e.ChannelResource.Disconnected -= new Disconnected(ChannelResource_Disconnected);
e.ChannelResource.Disconnect();
e.ChannelResource.Dispose();
Log.Write("Call complete.");
}
}
Private Shared Sub s_TelephonyServer_NewCall(sender As Object, e As VoiceElements.Client.NewCallEventArgs)
Try
Log.Write("NewCall Arrival! DNIS: {0} ANI: {1} Caller ID Name: {2}", e.ChannelResource.Dnis, e.ChannelResource.Ani, e.ChannelResource.CallerIdName)
e.ChannelResource.Disconnected += New Disconnected(ChannelResource_Disconnected)
Log.Write("Answering...")
e.ChannelResource.Answer()
Catch generatedExceptionName As HangupException
Log.Write("The Caller Hung up.")
Catch ex As Exception
Log.WriteException(ex, "New Call Event Exception")
Finally
e.ChannelResource.Disconnected -= New Disconnected(ChannelResource_Disconnected)
e.ChannelResource.Disconnect()
e.ChannelResource.Dispose()
Log.Write("Call complete.")
End Try
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also