/// <summary>
        /// Sends the specified message to an XML-RPC server to execute a remote procedure call.
        /// This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes.
        /// </summary>
        /// <param name="message">A <see cref="XmlRpcMessage"/> that represents the information needed to execute the remote procedure call.</param>
        /// <param name="userToken">A user-defined object that is passed to the method invoked when the asynchronous operation completes.</param>
        /// <remarks>
        ///     <para>
        ///         To receive notification when the remote procedure call has been sent or the operation has been cancelled, add an event handler to the <see cref="SendCompleted"/> event.
        ///         You can cancel a <see cref="SendAsync(XmlRpcMessage, Object)"/> operation by calling the <see cref="SendAsyncCancel()"/> method.
        ///     </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="message"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="InvalidOperationException">The <see cref="Host"/> is a <b>null</b> reference (Nothing in Visual Basic).</exception>
        /// <exception cref="InvalidOperationException">This <see cref="XmlRpcClient"/> has a <see cref="SendAsync(XmlRpcMessage, Object)"/> call in progress.</exception>
        //[HostProtectionAttribute(SecurityAction.LinkDemand, ExternalThreading = true)]
        public void SendAsync(XmlRpcMessage message, Object userToken)
        {
            Guard.ArgumentNotNull(message, "message");

            if (this.Host == null)
            {
                throw new InvalidOperationException(String.Format(null, "Unable to send XML-RPC message. The Host property has not been initialized. \n\r Message payload: {0}", message));
            }
            else if (this.SendOperationInProgress)
            {
                throw new InvalidOperationException(String.Format(null, "Unable to send XML-RPC message. The XmlRpcClient has a SendAsync call in progress. \n\r Message payload: {0}", message));
            }

            this.SendOperationInProgress   = true;
            this.AsyncSendHasBeenCancelled = false;

            asyncHttpWebRequest = XmlRpcClient.CreateWebRequest(this.Host, this.UserAgent, message, this.UseDefaultCredentials, this.clientOptions);

            object[] state = new object[6] {
                asyncHttpWebRequest, this, this.Host, message, this.clientOptions, userToken
            };
            IAsyncResult result = asyncHttpWebRequest.BeginGetResponse(new AsyncCallback(AsyncSendCallback), state);

            ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, new WaitOrTimerCallback(AsyncTimeoutCallback), state, this.Timeout, true);
        }
        /// <summary>
        /// Sends the specified message to an XML-RPC server to execute a remote procedure call.
        /// </summary>
        /// <param name="message">A <see cref="XmlRpcMessage"/> that represents the information needed to execute the remote procedure call.</param>
        /// <returns>A <see cref="XmlRpcResponse"/> that represents the server's response to the remote procedure call.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="message"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="InvalidOperationException">The <see cref="Host"/> is a <b>null</b> reference (Nothing in Visual Basic).</exception>
        /// <exception cref="InvalidOperationException">This <see cref="XmlRpcClient"/> has a <see cref="SendAsync(XmlRpcMessage, Object)"/> call in progress.</exception>
        public XmlRpcResponse Send(XmlRpcMessage message)
        {
            XmlRpcResponse response = null;

            Guard.ArgumentNotNull(message, "message");

            if (this.Host == null)
            {
                throw new InvalidOperationException(String.Format(null, "Unable to send XML-RPC message. The Host property has not been initialized. \n\r Message payload: {0}", message));
            }
            else if (this.SendOperationInProgress)
            {
                throw new InvalidOperationException(String.Format(null, "Unable to send XML-RPC message. The XmlRpcClient has a SendAsync call in progress. \n\r Message payload: {0}", message));
            }

            WebRequest webRequest = XmlRpcClient.CreateWebRequest(this.Host, this.UserAgent, message, this.UseDefaultCredentials, this.clientOptions);

            using (WebResponse webResponse = (WebResponse)webRequest.GetResponse())
            {
                response = new XmlRpcResponse(webResponse);
            }

            return(response);
        }