Beispiel #1
0
        public async Task DisconnectAsync()
        {
            if (client != null)
            {
                log.Debug(l => l(LogMessages.Disconnecting, Host));

                Device.Disconnect();
                await disconnected.Task;

                disconnectedTokenSource.Cancel();

                try
                {
                    await processMessagesTask;
                }
                catch (Exception e)
                {
                    if (!(e is OperationCanceledException))
                    {
                        log.Warn(l => l(LogMessages.ProcessMessagesTaskFailed), e);
                    }
                }
                processMessagesTask = null;

                connected    = null;
                disconnected = null;

                Device.Dispose();
                Device = null;
                client.Dispose();
                client = null;
            }
        }
Beispiel #2
0
        private bool disposedValue = false; // Для определения избыточных вызовов

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    SDK.Dispose();
                }

                SDK = null;

                disposedValue = true;
            }
        }