Example #1
0
        protected void Process()
        {
            while (bStarted)
            {
                while (mSessions.Count <= 0)
                {
                    System.Diagnostics.Debug.Write("\n****无连接处理,进入等待。。\n");
                    mWaitEvent.WaitOne();
                }
                int iCount = mSessions.Count;
                for (int i = 0; i < iCount; i++)
                {
                    SSLSession ss = OutSession();
                    if (ss != null)
                    {
                        ThreadPool.QueueUserWorkItem(new WaitCallback((object obj) =>
                        {
                            SSLSession ssls = (SSLSession)obj;
                            ProcessSession(ssls);
                        }), ss);
                    }
                    else
                    {
                        break;
                    }
                }

                Thread.Sleep(2000);
            }
        }
Example #2
0
 public void EnSession(SSLSession s)
 {
     lock (mLocker)
     {
         mSessions.Enqueue(s);
         mWaitEvent.Set();
     }
 }
Example #3
0
 protected void ProcessSession(SSLSession ss)
 {
     if (ss.IsAlive())
     {
         ss.PrcessRequest();
         this.EnSession(ss);
     }
     else
     {
         ss.Recycle();
         ss = null;
     }
 }
Example #4
0
        public SSLSession OutSession()
        {
            SSLSession ss = null;

            lock (mLocker)
            {
                if (mSessions.Count > 0)
                {
                    ss = mSessions.Dequeue();
                }
            }
            return(ss);
        }