private bool OnChannelOpened() { object obj2; bool flag2; Message message = this.requestor.CreateRequest(this.operation, this.target, this.currentToken, out obj2); if (message == null) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("NullSessionRequestMessage", new object[] { this.operation.ToString() }))); } SecuritySessionSecurityTokenProvider.ChannelOpenAsyncResultWrapper state = new SecuritySessionSecurityTokenProvider.ChannelOpenAsyncResultWrapper { Message = message, RequestState = obj2 }; bool flag = true; try { IAsyncResult result = this.channel.BeginRequest(message, this.timeoutHelper.RemainingTime(), Fx.ThunkCallback(new AsyncCallback(this.RequestCallback)), state); if (!result.CompletedSynchronously) { flag = false; return(false); } Message reply = this.channel.EndRequest(result); flag2 = this.OnReplyReceived(reply, obj2); } finally { if (flag) { state.Message.Close(); } } return(flag2); }
private void RequestCallback(IAsyncResult result) { if (!result.CompletedSynchronously) { SecuritySessionSecurityTokenProvider.ChannelOpenAsyncResultWrapper asyncState = (SecuritySessionSecurityTokenProvider.ChannelOpenAsyncResultWrapper)result.AsyncState; object requestState = asyncState.RequestState; bool flag = false; Exception exception = null; try { Message reply = this.channel.EndRequest(result); flag = this.OnReplyReceived(reply, requestState); if (flag) { this.OnOperationComplete(); } } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } flag = true; exception = exception2; this.OnOperationFailure(exception2); } finally { if (asyncState.Message != null) { asyncState.Message.Close(); } } if (flag) { base.Complete(false, exception); } } }