Beispiel #1
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner TCP session.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(TCP_ServerSession owner)
            {
                if (owner == null)
                {
                    throw new ArgumentNullException("owner");
                }

                m_pTcpSession = owner;

                SetState(AsyncOP_State.Active);

                try{
                    m_pSslStream = new SslStream(m_pTcpSession.TcpStream.SourceStream, true);
                    m_pSslStream.BeginAuthenticateAsServer(m_pTcpSession.m_pCertificate, this.BeginAuthenticateAsServerCompleted, null);
                }
                catch (Exception x) {
                    m_pException = x;
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock (m_pLock){
                    m_RiseCompleted = true;

                    return(m_State == AsyncOP_State.Active);
                }
            }
Beispiel #2
0
            /// <summary>
            /// Cleans up any resource being used.
            /// </summary>
            public void Dispose()
            {
                if (m_State == AsyncOP_State.Disposed)
                {
                    return;
                }
                SetState(AsyncOP_State.Disposed);

                m_pException  = null;
                m_pTcpSession = null;
                m_pSslStream  = null;

                this.CompletedAsync = null;
            }