Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / OpenCollectionAsyncResult.cs / 1 / OpenCollectionAsyncResult.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel { using System.Collections.Generic; using System.Threading; internal class OpenCollectionAsyncResult : AsyncResult { bool completedSynchronously; Exception exception; static AsyncCallback nestedCallback = DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Callback)); int count; TimeoutHelper timeoutHelper; public OpenCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IListcollection) : base(otherCallback, state) { this.timeoutHelper = new TimeoutHelper(timeout); completedSynchronously = true; count = collection.Count; if (count == 0) { Complete(true); return; } for (int index = 0; index < collection.Count; index++) { // Throw exception if there was a failure calling EndOpen in the callback (skips remaining items) if (this.exception != null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.exception); CallbackState callbackState = new CallbackState(this, collection[index]); IAsyncResult result = collection[index].BeginOpen(this.timeoutHelper.RemainingTime(), nestedCallback, callbackState); if (result.CompletedSynchronously) { collection[index].EndOpen(result); Decrement(true); } } } static void Callback(IAsyncResult result) { if (result.CompletedSynchronously) return; CallbackState callbackState = (CallbackState)result.AsyncState; try { callbackState.Instance.EndOpen(result); callbackState.Result.Decrement(false); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) throw; callbackState.Result.Decrement(false, e); } } void Decrement(bool completedSynchronously) { if (completedSynchronously == false) this.completedSynchronously = false; if (Interlocked.Decrement(ref count) == 0) { if (this.exception != null) Complete(this.completedSynchronously, this.exception); else Complete(this.completedSynchronously); } } void Decrement(bool completedSynchronously, Exception exception) { this.exception = exception; this.Decrement(completedSynchronously); } public static void End(IAsyncResult result) { AsyncResult.End (result); } class CallbackState { ICommunicationObject instance; OpenCollectionAsyncResult result; public CallbackState(OpenCollectionAsyncResult result, ICommunicationObject instance) { this.result = result; this.instance = instance; } public ICommunicationObject Instance { get { return instance; } } public OpenCollectionAsyncResult Result { get { return result; } } } } } // 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
- QueryContinueDragEvent.cs
- DataGridRowsPresenter.cs
- OracleCommandSet.cs
- RangeExpression.cs
- ResourceReader.cs
- Message.cs
- cryptoapiTransform.cs
- XmlSerializationWriter.cs
- updateconfighost.cs
- SvcMapFile.cs
- ThrowHelper.cs
- TableItemPattern.cs
- Identifier.cs
- CompositeCollection.cs
- TemplateBaseAction.cs
- MultiView.cs
- HTTPNotFoundHandler.cs
- Encoding.cs
- EventProviderWriter.cs
- _ConnectionGroup.cs
- LogLogRecordEnumerator.cs
- PasswordDeriveBytes.cs
- ProviderSettings.cs
- GenericRootAutomationPeer.cs
- OutputCacheProfile.cs
- ComponentResourceManager.cs
- EdmItemCollection.cs
- SafeMILHandle.cs
- CorrelationKeyCalculator.cs
- SchemaAttDef.cs
- TemplateBindingExtension.cs
- DocumentSchemaValidator.cs
- TransactionScope.cs
- SafeSecurityHelper.cs
- SchemaInfo.cs
- SamlAudienceRestrictionCondition.cs
- PersistNameAttribute.cs
- MultipleViewPatternIdentifiers.cs
- AttachedPropertyInfo.cs
- TcpTransportBindingElement.cs
- FunctionCommandText.cs
- CompositeKey.cs
- HeaderCollection.cs
- MailWriter.cs
- Assembly.cs
- AspCompat.cs
- MdbDataFileEditor.cs
- QilList.cs
- BindingMemberInfo.cs
- UriTemplateClientFormatter.cs
- _SslState.cs
- PlaceHolder.cs
- WindowsHyperlink.cs
- ListenerElementsCollection.cs
- ping.cs
- SafeNativeMethods.cs
- _SslStream.cs
- StatusBarAutomationPeer.cs
- TransformationRules.cs
- FocusManager.cs
- XmlChildNodes.cs
- VectorAnimationBase.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- SqlFactory.cs
- AspNetSynchronizationContext.cs
- ErrorRuntimeConfig.cs
- ProfileParameter.cs
- ObjectDataSourceEventArgs.cs
- Delegate.cs
- DmlSqlGenerator.cs
- ReliabilityContractAttribute.cs
- FamilyMap.cs
- DecimalKeyFrameCollection.cs
- WpfKnownMemberInvoker.cs
- PrimaryKeyTypeConverter.cs
- EditorBrowsableAttribute.cs
- WithStatement.cs
- ChangeDirector.cs
- TextTabProperties.cs
- SerializationInfoEnumerator.cs
- FontFamilyValueSerializer.cs
- DataChangedEventManager.cs
- XmlArrayAttribute.cs
- FileLogRecordHeader.cs
- ExpressionEditorAttribute.cs
- Slider.cs
- KnownIds.cs
- ParallelDesigner.cs
- ExtensionFile.cs
- ListenerServiceInstallComponent.cs
- ListCommandEventArgs.cs
- MethodBody.cs
- CollectionsUtil.cs
- LayoutTable.cs
- DataSourceXmlTextReader.cs
- ArrayElementGridEntry.cs
- AlphabetConverter.cs
- SqlNotificationRequest.cs
- X509Chain.cs
- SecurityRuntime.cs