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
- UnsafePeerToPeerMethods.cs
- HtmlDocument.cs
- HwndMouseInputProvider.cs
- InheritanceRules.cs
- PerformanceCounterManager.cs
- Executor.cs
- CollaborationHelperFunctions.cs
- DataTablePropertyDescriptor.cs
- ArrangedElementCollection.cs
- ReleaseInstanceMode.cs
- CodeAttributeDeclaration.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- DataSpaceManager.cs
- SQLResource.cs
- BinaryUtilClasses.cs
- WebPartEditVerb.cs
- ResourceSet.cs
- MessageEncodingBindingElementImporter.cs
- FtpWebRequest.cs
- CompilerParameters.cs
- WebAdminConfigurationHelper.cs
- FactoryId.cs
- MultiView.cs
- XmlSerializableReader.cs
- MachineKeyConverter.cs
- ProfileGroupSettings.cs
- OdbcUtils.cs
- ResourceIDHelper.cs
- SqlParameterizer.cs
- DataListItemEventArgs.cs
- Int64KeyFrameCollection.cs
- GradientSpreadMethodValidation.cs
- XmlLanguage.cs
- UpDownEvent.cs
- EntityClientCacheEntry.cs
- DataSourceCacheDurationConverter.cs
- WindowsAuthenticationModule.cs
- ComplexType.cs
- HashMembershipCondition.cs
- SizeConverter.cs
- PropertyContainer.cs
- DocumentViewerConstants.cs
- SmiSettersStream.cs
- BaseTemplateBuildProvider.cs
- ParallelActivityDesigner.cs
- Error.cs
- CqlBlock.cs
- Vector3DKeyFrameCollection.cs
- VoiceObjectToken.cs
- _HelperAsyncResults.cs
- InputReportEventArgs.cs
- VisualStyleRenderer.cs
- WebPartAuthorizationEventArgs.cs
- ManipulationLogic.cs
- DirectoryNotFoundException.cs
- FontStyleConverter.cs
- LocalizableAttribute.cs
- ImageAnimator.cs
- RoutedUICommand.cs
- ThemeableAttribute.cs
- ScrollItemPatternIdentifiers.cs
- WindowsGraphics2.cs
- TargetControlTypeAttribute.cs
- NamespaceQuery.cs
- DataGridHyperlinkColumn.cs
- DataContext.cs
- ObjectDisposedException.cs
- DataTemplateSelector.cs
- FormViewDeletedEventArgs.cs
- PrintPreviewGraphics.cs
- OrderByBuilder.cs
- DataGridViewAdvancedBorderStyle.cs
- InstallerTypeAttribute.cs
- ImpersonateTokenRef.cs
- XmlCountingReader.cs
- XPathMultyIterator.cs
- WebPartDisplayModeCancelEventArgs.cs
- NewExpression.cs
- CompleteWizardStep.cs
- VisualTreeUtils.cs
- ProjectionCamera.cs
- XmlAttributeOverrides.cs
- ButtonBaseAdapter.cs
- ExitEventArgs.cs
- XmlNavigatorStack.cs
- FloatUtil.cs
- EncodingNLS.cs
- DataGridViewIntLinkedList.cs
- XmlTextEncoder.cs
- HttpCookie.cs
- ContainerAction.cs
- RoleGroupCollection.cs
- XmlEnumAttribute.cs
- TextTabProperties.cs
- CodeDomSerializationProvider.cs
- ExpressionList.cs
- ImmutableDispatchRuntime.cs
- SingleSelectRootGridEntry.cs
- Variant.cs
- SocketInformation.cs