/// <summary>
        /// Get the oldest context from the context queue
        ///     the method would be block until there is a pending context
        /// </summary>
        /// <returns></returns>
        public FtpListenerContext GetContext()
        {
            FtpListenerContext context = null;

            if (m_ContextQueue == null)
            {
                throw new NullReferenceException("Context queue is empty");
            }
            // block the method until some context arrived
            m_ContextQueueLock.WaitOne();
            lock (m_ContextQueue.SyncRoot)
            {
                if (m_ContextQueue.Count > 0)
                {
                    context = m_ContextQueue.Dequeue() as FtpListenerContext;
                }
                // otherwise a null context will be returned;
            }
            return(context);
        }
 /// <summary>
 /// Add a context to the context queue and raise a reset event
 /// </summary>
 /// <param name="context"></param>
 internal void AddContext(FtpListenerContext context)
 {
     if (m_IsRunning)
     {
         if (m_ContextQueue == null)
         {
             m_ContextQueue = new Queue();
         }
         lock (m_ContextQueue.SyncRoot)
         {
             m_ContextQueue.Enqueue(context);
         }
         m_ContextQueueLock.Set();
     }
     else
     {
         // reject all context if the listener is not running
         context.Response.StatusCode = FtpStatusCode.ActionAbortedLocalProcessingError;
         context.Response.OutputStream.Close();
     }
 }
        /// <summary>
        /// Add a context to the context queue and raise a reset event
        /// </summary>
        /// <param name="context"></param>
        internal void AddContext(FtpListenerContext context)
        {
            if (m_IsRunning)
            {
                if (m_ContextQueue == null)
                {
                    m_ContextQueue = new Queue();
                }
                lock (m_ContextQueue.SyncRoot)
                {
                    m_ContextQueue.Enqueue(context);
                }
                m_ContextQueueLock.Set();
            }
            else
            {
                // reject all context if the listener is not running
                context.Response.StatusCode = FtpStatusCode.ActionAbortedLocalProcessingError;
                context.Response.OutputStream.Close();
            }

        }