Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Collections / Concurrent / IProducerConsumerCollection.cs / 1305376 / IProducerConsumerCollection.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // IProducerConsumerCollection.cs // //[....] // // A common interface for all concurrent collections. // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; using System.Diagnostics; namespace System.Collections.Concurrent { ////// Defines methods to manipulate thread-safe collections intended for producer/consumer usage. /// ///Specifies the type of elements in the collection. ////// All implementations of this interface must enable all members of this interface /// to be used concurrently from multiple threads. /// public interface IProducerConsumerCollection: IEnumerable , ICollection { /// /// Copies the elements of the /// The one-dimensionalto /// an /// , starting at a specified index. /// that is the destination of /// the elements copied from the . /// The array must have zero-based indexing. /// The zero-based index in at which copying /// begins. /// /// is a null reference (Nothing in /// Visual Basic). /// is less than /// zero. void CopyTo(T[] array, int index); /// is equal to or greater than the /// length of the /// -or- The number of elements in the source is greater than the /// available space from to the end of the destination . /// /// Attempts to add an object to the /// The object to add to the. /// . /// true if the object was added successfully; otherwise, false. ///The bool TryAdd(T item); ///was invalid for this collection. /// Attempts to remove and return an object from the /// /// When this method returns, if the object was removed and returned successfully,. /// contains the removed object. If no object was available to be removed, the value is /// unspecified. /// /// true if an object was removed and returned successfully; otherwise, false. bool TryTake(out T item); ////// Copies the elements contained in the ///to a new array. /// A new array containing the elements copied from the T[] ToArray(); } ///. /// A debugger view of the IProducerConsumerCollection that makes it simple to browse the /// collection's contents at a point in time. /// ///The type of elements stored within. internal sealed class SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView{ private IProducerConsumerCollection m_collection; // The collection being viewed. /// /// Constructs a new debugger view object for the provided collection object. /// /// A collection to browse in the debugger. public SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView(IProducerConsumerCollectioncollection) { if (collection == null) { throw new ArgumentNullException("collection"); } m_collection = collection; } /// /// Returns a snapshot of the underlying collection's elements. /// [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public T[] Items { get { return m_collection.ToArray(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // IProducerConsumerCollection.cs // //[....] // // A common interface for all concurrent collections. // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; using System.Diagnostics; namespace System.Collections.Concurrent { ////// Defines methods to manipulate thread-safe collections intended for producer/consumer usage. /// ///Specifies the type of elements in the collection. ////// All implementations of this interface must enable all members of this interface /// to be used concurrently from multiple threads. /// public interface IProducerConsumerCollection: IEnumerable , ICollection { /// /// Copies the elements of the /// The one-dimensionalto /// an /// , starting at a specified index. /// that is the destination of /// the elements copied from the . /// The array must have zero-based indexing. /// The zero-based index in at which copying /// begins. /// /// is a null reference (Nothing in /// Visual Basic). /// is less than /// zero. void CopyTo(T[] array, int index); /// is equal to or greater than the /// length of the /// -or- The number of elements in the source is greater than the /// available space from to the end of the destination . /// /// Attempts to add an object to the /// The object to add to the. /// . /// true if the object was added successfully; otherwise, false. ///The bool TryAdd(T item); ///was invalid for this collection. /// Attempts to remove and return an object from the /// /// When this method returns, if the object was removed and returned successfully,. /// contains the removed object. If no object was available to be removed, the value is /// unspecified. /// /// true if an object was removed and returned successfully; otherwise, false. bool TryTake(out T item); ////// Copies the elements contained in the ///to a new array. /// A new array containing the elements copied from the T[] ToArray(); } ///. /// A debugger view of the IProducerConsumerCollection that makes it simple to browse the /// collection's contents at a point in time. /// ///The type of elements stored within. internal sealed class SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView{ private IProducerConsumerCollection m_collection; // The collection being viewed. /// /// Constructs a new debugger view object for the provided collection object. /// /// A collection to browse in the debugger. public SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView(IProducerConsumerCollectioncollection) { if (collection == null) { throw new ArgumentNullException("collection"); } m_collection = collection; } /// /// Returns a snapshot of the underlying collection's elements. /// [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public T[] Items { get { return m_collection.ToArray(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InstanceCreationEditor.cs
- SmtpNtlmAuthenticationModule.cs
- BindingList.cs
- ViewManager.cs
- TransactionsSectionGroup.cs
- OlePropertyStructs.cs
- FixedSOMPageConstructor.cs
- InfoCardClaimCollection.cs
- CalendarDesigner.cs
- GenericIdentity.cs
- ProcessModelSection.cs
- NullableDecimalSumAggregationOperator.cs
- configsystem.cs
- SkewTransform.cs
- SafeNativeMemoryHandle.cs
- PageParser.cs
- ScalarType.cs
- DataKey.cs
- Rect.cs
- Itemizer.cs
- Model3DGroup.cs
- XmlDataFileEditor.cs
- COM2EnumConverter.cs
- LowerCaseStringConverter.cs
- ComponentChangedEvent.cs
- Internal.cs
- ViewService.cs
- XmlSchemaSubstitutionGroup.cs
- URLMembershipCondition.cs
- XamlSerializationHelper.cs
- SecuritySessionSecurityTokenProvider.cs
- TemplateControlBuildProvider.cs
- loginstatus.cs
- TextStore.cs
- FormViewDeletedEventArgs.cs
- WindowsFormsLinkLabel.cs
- WebReferenceOptions.cs
- ServiceModelInstallComponent.cs
- HttpErrorTraceRecord.cs
- PlainXmlSerializer.cs
- ProcessModule.cs
- FrameworkTemplate.cs
- ItemsControlAutomationPeer.cs
- UnSafeCharBuffer.cs
- QueueProcessor.cs
- _ContextAwareResult.cs
- RemotingConfiguration.cs
- OrderToken.cs
- LinkedResourceCollection.cs
- XmlCountingReader.cs
- BasicCellRelation.cs
- LocalFileSettingsProvider.cs
- AbstractDataSvcMapFileLoader.cs
- MeasureItemEvent.cs
- ProfileInfo.cs
- CanExecuteRoutedEventArgs.cs
- DetailsViewUpdateEventArgs.cs
- MinMaxParagraphWidth.cs
- ConfigXmlText.cs
- dbdatarecord.cs
- AttributeQuery.cs
- ObjectDataSourceChooseMethodsPanel.cs
- __TransparentProxy.cs
- HtmlAnchor.cs
- CollectionViewGroupInternal.cs
- OutgoingWebResponseContext.cs
- HtmlInputSubmit.cs
- HwndSourceParameters.cs
- PropertyReferenceExtension.cs
- KnownTypesHelper.cs
- ListViewUpdatedEventArgs.cs
- LinkLabelLinkClickedEvent.cs
- ReflectionTypeLoadException.cs
- InkCanvasSelection.cs
- JsonUriDataContract.cs
- ComponentGlyph.cs
- DataControlField.cs
- SQLInt64Storage.cs
- BridgeDataReader.cs
- XmlWhitespace.cs
- OdbcReferenceCollection.cs
- XmlObjectSerializerReadContextComplexJson.cs
- versioninfo.cs
- SystemDropShadowChrome.cs
- UpWmlMobileTextWriter.cs
- TargetFrameworkAttribute.cs
- DictionaryEditChange.cs
- BitmapImage.cs
- HMACSHA1.cs
- Keywords.cs
- CompareInfo.cs
- Metadata.cs
- XmlSchemaRedefine.cs
- StaticFileHandler.cs
- PatternMatcher.cs
- ServiceMemoryGates.cs
- SoapEnumAttribute.cs
- SettingsContext.cs
- EntityDesignPluralizationHandler.cs
- ManagedCodeMarkers.cs