/// <summary> /// Checks for a valid IAsyncResult object and returns the original request object. /// </summary> /// <param name="ar">The IAsyncResult object for the operation.</param> /// <returns>The request object if available; otherwise null.</returns> public static IServiceRequest GetRequest(IAsyncResult ar) { SendRequestAsyncResult result = ar as SendRequestAsyncResult; if (result != null) { return(result.m_request); } return(null); }
/// <summary> /// Completes an asynchronous operation to send a request over the secure channel. /// </summary> public IServiceResponse EndSendRequest(IAsyncResult result) { if (m_wcfBypassChannel != null) { return(m_wcfBypassChannel.EndSendRequest(result)); } #if MANAGE_CHANNEL_THREADS return(SendRequestAsyncResult.WaitForComplete(result)); #else InvokeServiceResponseMessage responseMessage = EndInvokeService(result); return((IServiceResponse)BinaryDecoder.DecodeMessage(responseMessage.InvokeServiceResponse, null, m_messageContext)); #endif }
/// <summary> /// Begins an asynchronous operation to send a request over the secure channel. /// </summary> public IAsyncResult BeginSendRequest(IServiceRequest request, AsyncCallback callback, object callbackData) { if (m_wcfBypassChannel != null) { return(m_wcfBypassChannel.BeginSendRequest(request, callback, callbackData)); } #if MANAGE_CHANNEL_THREADS SendRequestAsyncResult asyncResult = new SendRequestAsyncResult(this, callback, callbackData, 0); asyncResult.BeginSendRequest(SendRequest, request); return(asyncResult); #else byte[] requestMessage = BinaryEncoder.EncodeMessage(request, m_messageContext); return(BeginInvokeService(new InvokeServiceMessage(requestMessage), callback, callbackData)); #endif }
/// <summary> /// Checks for a valid IAsyncResult object and waits for the operation to complete. /// </summary> /// <param name="ar">The IAsyncResult object for the operation.</param> /// <returns>The response.</returns> public static new IServiceResponse WaitForComplete(IAsyncResult ar) { SendRequestAsyncResult result = ar as SendRequestAsyncResult; if (result == null) { throw new ArgumentException("End called with an invalid IAsyncResult object.", "ar"); } if (result.m_response == null && result.m_error == null) { if (!result.WaitForComplete()) { throw new TimeoutException(); } } if (result.m_error != null) { throw new ServiceResultException(result.m_error, StatusCodes.BadInternalError); } return(result.m_response); }
/// <summary> /// Begins an asynchronous operation to send a request over the secure channel. /// </summary> public IAsyncResult BeginSendRequest(IServiceRequest request, AsyncCallback callback, object callbackData) { if (m_wcfBypassChannel != null) { return m_wcfBypassChannel.BeginSendRequest(request, callback, callbackData); } #if MANAGE_CHANNEL_THREADS SendRequestAsyncResult asyncResult = new SendRequestAsyncResult(this, callback, callbackData, 0); asyncResult.BeginSendRequest(SendRequest, request); return asyncResult; #else byte[] requestMessage = BinaryEncoder.EncodeMessage(request, m_messageContext); return BeginInvokeService(new InvokeServiceMessage(requestMessage), callback, callbackData); #endif }