Ejemplo n.º 1
0
        private void DestroyInternal()
        {
            IRouterPrx   router;
            Communicator?communicator;

            lock (_mutex)
            {
                Debug.Assert(_destroy);
                if (_router == null)
                {
                    return;
                }
                router  = _router;
                _router = null;

                communicator = _communicator;

                Debug.Assert(communicator != null);
            }

            try
            {
                router.DestroySession();
            }
            catch (ConnectionLostException)
            {
                // Expected if another thread invoked on an object from the session concurrently.
            }
            catch (SessionNotExistException)
            {
                // This can also occur.
            }
            catch (Exception e)
            {
                communicator.Logger.Warning("SessionHelper: unexpected exception when destroying the session:\n" + e);
            }

            communicator.Dispose();

            // Notify the callback that the session is gone.
            _callback.Disconnected(this);
        }