/// <summary>
 /// Close the frontend for send request
 /// </summary>
 /// <param name="setToNull">Whether to set client object to null after closing. THis should only be true if caller is within BrokerClient's objectLock to ensure
 /// another thread isnt using or about to use it</param>
 /// <param name="timeoutInMS">How long to wait for close. -1 means use binding's close timeout</param>
 public override void CloseBrokerClient(bool setToNull, int timeoutInMS)
 {
     if (this.frontendForSendRequest != null)
     {
         lock (this.lockToCreateWebBrokerFrontendForSendRequest)
         {
             if (this.frontendForSendRequest != null)
             {
                 this.frontendForSendRequest.Close();
                 if (setToNull)
                 {
                     this.frontendForSendRequest = null;
                 }
             }
         }
     }
 }
        /// <summary>
        /// Gets the instance of the WebBrokerFrontendForSendRequest class
        /// Create one if it does not exist
        /// </summary>
        /// <returns>returns the instance of the WebBrokerFrontendForSendRequest class</returns>
        private WebBrokerFrontendForSendRequest GetWebBrokerFrontendForSendRequest()
        {
            if (this.frontendForSendRequest == null || this.frontendForSendRequest.IsFaulted)
            {
                lock (this.lockToCreateWebBrokerFrontendForSendRequest)
                {
                    if (this.frontendForSendRequest != null && this.frontendForSendRequest.IsFaulted)
                    {
                        SessionBase.TraceSource.TraceInformation("FrontendForSendRequest is in Faulted state. Recreate it.");

                        this.frontendForSendRequest.Close();
                        this.frontendForSendRequest = null;
                    }

                    if (this.frontendForSendRequest == null)
                    {
                        this.frontendForSendRequest = new WebBrokerFrontendForSendRequest(
                            info.BrokerNode, info.Id, this.ClientId, info.Credential);
                    }
                }
            }

            return(this.frontendForSendRequest);
        }