PrepareSharingNtlm() static private méthode

static private PrepareSharingNtlm ( WebConnection cnc, HttpWebRequest request ) : void
cnc WebConnection
request HttpWebRequest
Résultat void
Exemple #1
0
        private WebConnection CreateOrReuseConnection(HttpWebRequest request)
        {
            int           num = this.connections.Count;
            WebConnection webConnection;

            for (int i = 0; i < num; i++)
            {
                WeakReference weakReference = this.connections[i] as WeakReference;
                webConnection = (weakReference.Target as WebConnection);
                if (webConnection == null)
                {
                    this.connections.RemoveAt(i);
                    num--;
                    i--;
                }
                else if (!webConnection.Busy)
                {
                    WebConnectionGroup.PrepareSharingNtlm(webConnection, request);
                    return(webConnection);
                }
            }
            if (this.sPoint.ConnectionLimit > num)
            {
                webConnection = new WebConnection(this, this.sPoint);
                this.connections.Add(new WeakReference(webConnection));
                return(webConnection);
            }
            if (this.rnd == null)
            {
                this.rnd = new Random();
            }
            int           index          = (num <= 1) ? 0 : this.rnd.Next(0, num - 1);
            WeakReference weakReference2 = (WeakReference)this.connections[index];

            webConnection = (weakReference2.Target as WebConnection);
            if (webConnection == null)
            {
                webConnection = new WebConnection(this, this.sPoint);
                this.connections.RemoveAt(index);
                this.connections.Add(new WeakReference(webConnection));
            }
            return(webConnection);
        }