Exemplo n.º 1
0
        void OnDisconnected(ExceptionalEventArgs e)
        {
            #pragma warning disable 420
            if (Interlocked.Increment(ref disconnectsFired) > 1)
            {
                return;
            }
            #pragma warning restore 420

            if (writer != null)
            {
                writer.Continue = false;
            }
            if (reader != null)
            {
                reader.Continue = false;
            }

            try { writerThread.Abort(); } catch { }
            try { readerThread.Abort(); } catch { }

            WrapCallback(() =>
            {
                if (Disconnected != null)
                {
                    Disconnected(this, e);
                }
            });

            if (throwDisconnect)
            {
                WrapCallback(() => callbackManager.SetExceptionForAll(
                                 new ClientDisconnectedException(e.Description, e.Exception)));
            }
        }
Exemplo n.º 2
0
        public void OnDisconnected(ExceptionalEventArgs e)
        {
            if (Interlocked.Increment(ref disconnectsFired) > 1)
            {
                return;
            }

            HasConnected = false;
            WrapCallback(() => Disconnected?.Invoke(this, e));
            WrapCallback(() => callbackManager.SetExceptionForAll(new ClientDisconnectedException(e.Description, e.Exception)));
            Dispose(true);
        }
Exemplo n.º 3
0
        private void OnDisconnected(ExceptionalEventArgs e)
        {
            if (IsDisconnected)
            {
                return;
            }
            IsDisconnected = true;

            if (_writer != null)
            {
                _writer.Continue = false;
            }
            if (_reader != null)
            {
                _reader.Continue = false;
            }

            try
            {
                _writerThread.Abort();
            }
            catch
            {
            }
            try
            {
                _readerThread.Abort();
            }
            catch
            {
            }

            WrapCallback(
                () => _callbackManager.SetExceptionForAll(new ClientDisconnectedException(e.Description, e.Exception)));
            _invokeId = 0;

            WrapCallback(() =>
            {
                if (Disconnected != null)
                {
                    Disconnected(this, e);
                }
            });
        }