protected override void Dispose(bool disposing)
{
if (!m_disposed)
{
try
{
// This will be done regardless of whether the object is finalized or disposed.
if (disposing)
{
// This will be done only when the object is disposed by calling Dispose().
Disconnect();
SaveSettings();
if ((object)m_remotingClient != null)
{
// Detach events from any existing instance
m_remotingClient.ConnectionEstablished -= RemotingClient_ConnectionEstablished;
m_remotingClient.ConnectionAttempt -= RemotingClient_ConnectionAttempt;
m_remotingClient.ConnectionException -= RemotingClient_ConnectionException;
m_remotingClient.ConnectionTerminated -= RemotingClient_ConnectionTerminated;
m_remotingClient.ReceiveDataComplete -= RemotingClient_ReceiveDataComplete;
}
}
}
finally
{
m_disposed = true; // Prevent duplicate dispose.
base.Dispose(disposing); // Call base class Dispose().
}
}
}