public static void IncrementTargetBackendDagAndForest(ProxyRequestHandler request)
        {
            string bucketName;
            string text;
            string text2;

            if (ConcurrencyGuardHelper.TryGetBackendDagAndForest(request, out bucketName, out text, out text2))
            {
                ConcurrencyGuards.TargetBackend.Increment(bucketName, request.Logger);
                ConcurrencyGuards.TargetForest.Increment(text2, request.Logger);
                ConcurrencyGuardHelper.GetPerfCounter(text2).OutstandingProxyRequestsToForest.Increment();
                PerfCounters.HttpProxyCountersInstance.OutstandingProxyRequests.Increment();
            }
        }
 private void OnProxyLogonRequestStreamReady(object extraData)
 {
     base.CallThreadEntranceMethod(delegate
     {
         IAsyncResult asyncResult = extraData as IAsyncResult;
         lock (this.LockObject)
         {
             try
             {
                 this.proxyLogonRequestStream = this.proxyLogonRequest.EndGetRequestStream(asyncResult);
                 this.proxyLogonRequestStream.Write(this.proxyLogonCSC, 0, this.proxyLogonCSC.Length);
                 this.proxyLogonRequestStream.Flush();
                 this.proxyLogonRequestStream.Dispose();
                 this.proxyLogonRequestStream = null;
                 try
                 {
                     ConcurrencyGuardHelper.IncrementTargetBackendDagAndForest(this);
                     this.proxyLogonRequest.BeginGetResponse(new AsyncCallback(OwaEcpProxyRequestHandler <ServiceType> .ProxyLogonResponseReadyCallback), this.ServerAsyncState);
                     this.State = ProxyRequestHandler.ProxyState.WaitForProxyLogonResponse;
                 }
                 catch (Exception)
                 {
                     ConcurrencyGuardHelper.DecrementTargetBackendDagAndForest(this);
                     throw;
                 }
             }
             catch (WebException ex)
             {
                 this.CompleteWithError(ex, "[OwaEcpProxyRequestHandler::OnProxyLogonRequestStreamReady]");
             }
             catch (HttpException ex2)
             {
                 this.CompleteWithError(ex2, "[OwaEcpProxyRequestHandler::OnProxyLogonRequestStreamReady]");
             }
             catch (HttpProxyException ex3)
             {
                 this.CompleteWithError(ex3, "[OwaEcpProxyRequestHandler::OnProxyLogonRequestStreamReady]");
             }
             catch (IOException ex4)
             {
                 this.CompleteWithError(ex4, "[OwaEcpProxyRequestHandler::OnProxyLogonRequestStreamReady]");
             }
         }
     });
 }
 private void OnProxyLogonResponseReady(object extraData)
 {
     base.CallThreadEntranceMethod(delegate
     {
         IAsyncResult asyncResult = extraData as IAsyncResult;
         lock (this.LockObject)
         {
             try
             {
                 ConcurrencyGuardHelper.DecrementTargetBackendDagAndForest(this);
                 this.proxyLogonResponse = (HttpWebResponse)this.proxyLogonRequest.EndGetResponse(asyncResult);
                 this.PfdTracer.TraceResponse("ProxyLogonResponse", this.proxyLogonResponse);
                 this.proxyLogonResponseCookies = this.proxyLogonResponse.Cookies;
                 this.proxyLogonResponse.Close();
                 this.proxyLogonResponse             = null;
                 UserContextCookie userContextCookie = this.TryGetUserContextFromProxyLogonResponse();
                 if (userContextCookie != null && userContextCookie.MailboxUniqueKey != null)
                 {
                     string mailboxUniqueKey = userContextCookie.MailboxUniqueKey;
                     if (SmtpAddress.IsValidSmtpAddress(mailboxUniqueKey))
                     {
                         ProxyAddress proxyAddress   = ProxyAddress.Parse("SMTP", mailboxUniqueKey);
                         AnchorMailbox anchorMailbox = new SmtpAnchorMailbox(proxyAddress.AddressString, this);
                         this.AnchoredRoutingTarget  = new AnchoredRoutingTarget(anchorMailbox, this.AnchoredRoutingTarget.BackEndServer);
                     }
                     else
                     {
                         try
                         {
                             SecurityIdentifier sid       = new SecurityIdentifier(mailboxUniqueKey);
                             AnchorMailbox anchorMailbox2 = new SidAnchorMailbox(sid, this);
                             this.AnchoredRoutingTarget   = new AnchoredRoutingTarget(anchorMailbox2, this.AnchoredRoutingTarget.BackEndServer);
                         }
                         catch (ArgumentException)
                         {
                         }
                     }
                 }
                 ThreadPool.QueueUserWorkItem(new WaitCallback(this.BeginProxyRequest));
                 this.State = ProxyRequestHandler.ProxyState.PrepareServerRequest;
             }
             catch (WebException ex)
             {
                 if (ex.Status == WebExceptionStatus.ProtocolError && ((HttpWebResponse)ex.Response).StatusCode == (HttpStatusCode)442)
                 {
                     this.RedirectOn442Response();
                 }
                 else
                 {
                     this.CompleteWithError(ex, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
                 }
             }
             catch (HttpException ex2)
             {
                 this.CompleteWithError(ex2, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
             catch (IOException ex3)
             {
                 this.CompleteWithError(ex3, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
             catch (HttpProxyException ex4)
             {
                 this.CompleteWithError(ex4, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
         }
     });
 }