Example #1
0
        /// <summary>
        ///     Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (connectionHandler != null)
            {
                connectionHandler.UnRegisterForMessage(MqttMessageType.SubscribeAck, ConfirmSubscription);
            }

            GC.SuppressFinalize(this);
        }
Example #2
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            // enter the monitor. If a ping is currently in progress, then wait for it complete before
            // disposing. Never release this monitor, we're going down anyway.
            Monitor.Enter(shutdownPadlock);
            this.disposed = true;

            if (connectionHandler != null)
            {
                connectionHandler.UnRegisterForMessage(MqttMessageType.PingRequest, PingRequestReceived);
                connectionHandler.UnRegisterForMessage(MqttMessageType.PingResponse, PingResponseReceived);
                connectionHandler.UnRegisterForAllSentMessages(MessageSent);
            }

            if (pingTimer != null)
            {
                pingTimer.Dispose();
            }

            GC.SuppressFinalize(this);
        }