Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / ReceiveMessageAndVerifySecurityAsyncResultBase.cs / 1 / ReceiveMessageAndVerifySecurityAsyncResultBase.cs
//---------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Security { using System.Runtime.InteropServices; using System.ServiceModel.Channels; abstract class ReceiveMessageAndVerifySecurityAsyncResultBase : AsyncResult { static AsyncCallback innerTryReceiveCompletedCallback = DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(InnerTryReceiveCompletedCallback)); Message message; bool receiveCompleted; TimeoutHelper timeoutHelper; IInputChannel innerChannel; protected ReceiveMessageAndVerifySecurityAsyncResultBase(IInputChannel innerChannel, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.timeoutHelper = new TimeoutHelper(timeout); this.innerChannel = innerChannel; } public void Start() { IAsyncResult asyncResult = innerChannel.BeginTryReceive(this.timeoutHelper.RemainingTime(), innerTryReceiveCompletedCallback, this); if (!asyncResult.CompletedSynchronously) { return; } bool innerReceiveCompleted = innerChannel.EndTryReceive(asyncResult, out this.message); if (!innerReceiveCompleted) { receiveCompleted = false; } else { receiveCompleted = true; bool completedSynchronously = this.OnInnerReceiveDone(ref this.message, this.timeoutHelper.RemainingTime()); if (!completedSynchronously) { return; } } Complete(true); } static void InnerTryReceiveCompletedCallback(IAsyncResult result) { if (result.CompletedSynchronously) { return; } ReceiveMessageAndVerifySecurityAsyncResultBase thisResult = (ReceiveMessageAndVerifySecurityAsyncResultBase)result.AsyncState; Exception completionException = null; bool completeSelf = false; try { bool innerReceiveCompleted = thisResult.innerChannel.EndTryReceive(result, out thisResult.message); if (!innerReceiveCompleted) { thisResult.receiveCompleted = false; completeSelf = true; } else { thisResult.receiveCompleted = true; completeSelf = thisResult.OnInnerReceiveDone(ref thisResult.message, thisResult.timeoutHelper.RemainingTime()); } } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (Diagnostics.ExceptionUtility.IsFatal(e)) throw; completeSelf = true; completionException = e; } if (completeSelf) { thisResult.Complete(false, completionException); } } protected abstract bool OnInnerReceiveDone(ref Message message, TimeSpan timeout); public static bool End(IAsyncResult result, out Message message) { ReceiveMessageAndVerifySecurityAsyncResultBase thisResult = AsyncResult.End(result); message = thisResult.message; return thisResult.receiveCompleted; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StaticSiteMapProvider.cs
- DbQueryCommandTree.cs
- ExecutedRoutedEventArgs.cs
- EDesignUtil.cs
- DataGridTablesFactory.cs
- ClientScriptManager.cs
- ExtendedPropertyInfo.cs
- StreamWriter.cs
- MissingMemberException.cs
- XmlDataLoader.cs
- Style.cs
- ConcurrentDictionary.cs
- XmlSerializerFactory.cs
- SqlFunctionAttribute.cs
- MemberDescriptor.cs
- HtmlElementErrorEventArgs.cs
- CodeAttachEventStatement.cs
- DbTypeMap.cs
- IdentityReference.cs
- UpdateRecord.cs
- DnsPermission.cs
- SqlCommandSet.cs
- ControlIdConverter.cs
- TransformPatternIdentifiers.cs
- NavigationProperty.cs
- ApplicationCommands.cs
- JoinSymbol.cs
- LiteralControl.cs
- WebControl.cs
- DefaultValueAttribute.cs
- UpdateManifestForBrowserApplication.cs
- HtmlProps.cs
- FutureFactory.cs
- InstanceOwnerQueryResult.cs
- _NegotiateClient.cs
- ObjectAnimationUsingKeyFrames.cs
- XmlAnyElementAttributes.cs
- XmlDeclaration.cs
- SafeProcessHandle.cs
- XmlBuffer.cs
- Wildcard.cs
- StateBag.cs
- Matrix3D.cs
- DataSet.cs
- PropertyValue.cs
- PersistenceTask.cs
- AudioSignalProblemOccurredEventArgs.cs
- MemoryMappedFileSecurity.cs
- SemaphoreSecurity.cs
- MediaCommands.cs
- ButtonColumn.cs
- EntityDesignerDataSourceView.cs
- FixedSOMTableCell.cs
- HtmlInputControl.cs
- DbgCompiler.cs
- CodeDOMUtility.cs
- LongValidatorAttribute.cs
- ExtensionQuery.cs
- FileDetails.cs
- DbModificationCommandTree.cs
- GridViewUpdatedEventArgs.cs
- AggregationMinMaxHelpers.cs
- TextDataBindingHandler.cs
- SystemWebCachingSectionGroup.cs
- CancellationTokenRegistration.cs
- LinkConverter.cs
- HttpException.cs
- FrameSecurityDescriptor.cs
- CommandEventArgs.cs
- DataContractSet.cs
- ObjectPersistData.cs
- ScalarRestriction.cs
- CodePrimitiveExpression.cs
- OrthographicCamera.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- ColorConverter.cs
- InputScopeNameConverter.cs
- LinearQuaternionKeyFrame.cs
- HMACSHA256.cs
- SymmetricAlgorithm.cs
- Int64Storage.cs
- DataGridViewRowHeaderCell.cs
- ListMarkerLine.cs
- SqlProvider.cs
- HttpApplicationFactory.cs
- CookieHandler.cs
- LostFocusEventManager.cs
- SecurityHelper.cs
- MonitoringDescriptionAttribute.cs
- Axis.cs
- MetadataArtifactLoaderCompositeResource.cs
- WebPartUserCapability.cs
- HttpRawResponse.cs
- ClientSideProviderDescription.cs
- TrackingParticipant.cs
- XamlPathDataSerializer.cs
- ModelPropertyDescriptor.cs
- BulletDecorator.cs
- TreeView.cs
- PathStreamGeometryContext.cs