/// <include file='doc\HttpClientProtocol.uex' path='docs/doc[@for="HttpSimpleClientProtocol.InvokeAsync1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void InvokeAsync(string methodName, string requestUrl, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = NullToken; } AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, null, null, new AsyncCallback(InvokeAsyncCallback), asyncOp); try { AsyncInvokes.Add(userState, asyncResult); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "InvokeAsync", e); } Exception exception = new ArgumentException(Res.GetString(Res.AsyncDuplicateUserState), e); InvokeCompletedEventArgs eventArgs = new InvokeCompletedEventArgs(new object[] { null }, exception, false, userState); asyncOp.PostOperationCompleted(callback, eventArgs); return; } try { HttpClientMethod method = GetClientMethod(methodName); MimeParameterWriter paramWriter = GetParameterWriter(method); Uri requestUri = new Uri(requestUrl); if (paramWriter != null) { paramWriter.RequestEncoding = RequestEncoding; requestUrl = paramWriter.GetRequestUrl(requestUri.AbsoluteUri, parameters); requestUri = new Uri(requestUrl, true); } asyncResult.InternalAsyncState = new InvokeAsyncState(method, paramWriter, parameters); BeginSend(requestUri, asyncResult, paramWriter.UsesWriteRequest); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "InvokeAsync", e); } OperationCompleted(userState, new object[] { null }, e, false); } }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapClientProtocol.InvokeAsync1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void InvokeAsync(string methodName, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = NullToken; } InvokeAsyncState invokeState = new InvokeAsyncState(methodName, parameters); AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, invokeState, null, new AsyncCallback(InvokeAsyncCallback), asyncOp); try { AsyncInvokes.Add(userState, asyncResult); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", e); } Exception exception = new ArgumentException(Res.GetString(Res.AsyncDuplicateUserState), e); InvokeCompletedEventArgs eventArgs = new InvokeCompletedEventArgs(new object[] { null }, exception, false, userState); asyncOp.PostOperationCompleted(callback, eventArgs); return; } try { BeginSend(Uri, asyncResult, true); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", e); } OperationCompleted(userState, new object[] { null }, e, false); } }