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
- DBCSCodePageEncoding.cs
- XmlFormatExtensionPrefixAttribute.cs
- InternalBase.cs
- IPGlobalProperties.cs
- StatusBarItemAutomationPeer.cs
- DbDataAdapter.cs
- TemplateControl.cs
- GPRECTF.cs
- MediaEntryAttribute.cs
- TextEditorContextMenu.cs
- FileLogRecord.cs
- HebrewCalendar.cs
- AddValidationError.cs
- DispatcherExceptionFilterEventArgs.cs
- UserControl.cs
- ViewKeyConstraint.cs
- MaterialGroup.cs
- X509RecipientCertificateServiceElement.cs
- QilInvoke.cs
- TypeDescriptor.cs
- GlobalEventManager.cs
- CookieProtection.cs
- RadioButtonRenderer.cs
- AdapterUtil.cs
- SubqueryRules.cs
- SchemaMapping.cs
- CipherData.cs
- SerializationInfo.cs
- ExternalException.cs
- FileAuthorizationModule.cs
- ProtectedConfigurationProviderCollection.cs
- ExpressionDumper.cs
- XmlArrayAttribute.cs
- TextBreakpoint.cs
- CodeSubDirectory.cs
- TriggerBase.cs
- ErrorFormatterPage.cs
- TCPClient.cs
- FileLoadException.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- PartitionedStream.cs
- ValidationRuleCollection.cs
- WebPartPersonalization.cs
- HttpApplicationStateBase.cs
- UIElementParagraph.cs
- formatstringdialog.cs
- WebPartDisplayMode.cs
- RecognizerInfo.cs
- StateManagedCollection.cs
- MediaElementAutomationPeer.cs
- LiteralControl.cs
- MasterPageParser.cs
- GuidelineSet.cs
- ViewPort3D.cs
- XmlNodeChangedEventManager.cs
- TypeUtils.cs
- OrderedDictionary.cs
- nulltextnavigator.cs
- PtsPage.cs
- GetIndexBinder.cs
- DataSet.cs
- ActivityBindForm.cs
- Int32EqualityComparer.cs
- RegistryKey.cs
- Path.cs
- ErrorsHelper.cs
- ChangeBlockUndoRecord.cs
- GroupStyle.cs
- DetailsViewInsertedEventArgs.cs
- GlyphRun.cs
- SqlSupersetValidator.cs
- OAVariantLib.cs
- UnaryQueryOperator.cs
- XomlCompiler.cs
- DataGridLinkButton.cs
- ByteAnimation.cs
- DispatcherSynchronizationContext.cs
- TrimSurroundingWhitespaceAttribute.cs
- FormatVersion.cs
- XsltException.cs
- DefaultValidator.cs
- TemplateComponentConnector.cs
- ManagementEventWatcher.cs
- Deserializer.cs
- AutomationFocusChangedEventArgs.cs
- SoapAttributes.cs
- webbrowsersite.cs
- AutoResetEvent.cs
- PointAnimationUsingPath.cs
- xmlfixedPageInfo.cs
- SuppressMessageAttribute.cs
- FontFamily.cs
- GridEntryCollection.cs
- NullableBoolConverter.cs
- StylusEditingBehavior.cs
- MachineSettingsSection.cs
- SafeHandles.cs
- HtmlPhoneCallAdapter.cs
- BufferedStream.cs
- BasePropertyDescriptor.cs