Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / Utils / CancellableEnumerable.cs / 1305376 / CancellableEnumerable.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // CancellableEnumerable.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Linq.Parallel; namespace System.Linq.Parallel { internal static class CancellableEnumerable { ////// Wraps an enumerable with a cancellation checker. The enumerator handed out by the source enumerable /// will be wrapped by an object that periodically checks whether a particular cancellation token has /// been cancelled. If so, the next call to MoveNext() will throw an OperationCancelledException. /// internal static IEnumerableWrap (IEnumerable source, CancellationToken token) { int count = 0; foreach (TElement element in source) { if ((count++ & CancellationState.POLL_INTERVAL) == 0) CancellationState.ThrowIfCanceled(token); yield return element; } } } } // 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
- MethodBuilderInstantiation.cs
- DocComment.cs
- ProtocolsConfiguration.cs
- DataGridViewCellStyle.cs
- WebPartZoneBase.cs
- oledbmetadatacollectionnames.cs
- ImmutableCollection.cs
- ComPlusTraceRecord.cs
- SchemaReference.cs
- DataGridViewHeaderCell.cs
- XamlPathDataSerializer.cs
- PointUtil.cs
- LinkArea.cs
- Guid.cs
- DataGridViewColumnHeaderCell.cs
- Frame.cs
- Win32.cs
- ObjectQueryState.cs
- DrawListViewColumnHeaderEventArgs.cs
- Marshal.cs
- AttributeCollection.cs
- XamlFigureLengthSerializer.cs
- Error.cs
- XmlNotation.cs
- basecomparevalidator.cs
- DbBuffer.cs
- MetadataPropertyvalue.cs
- AppDomain.cs
- CatalogZoneBase.cs
- XmlSchemaNotation.cs
- EntityViewContainer.cs
- TypeConverter.cs
- SmtpNetworkElement.cs
- InvalidDataException.cs
- SimpleTableProvider.cs
- TextCompositionEventArgs.cs
- SoapMessage.cs
- ProgressChangedEventArgs.cs
- XomlCompilerParameters.cs
- ScriptManagerProxy.cs
- SchemaImporterExtensionsSection.cs
- LogArchiveSnapshot.cs
- CookielessHelper.cs
- DataGridViewCellCollection.cs
- Header.cs
- CustomErrorsSection.cs
- DataKeyArray.cs
- designeractionlistschangedeventargs.cs
- IgnoreFileBuildProvider.cs
- XamlSerializerUtil.cs
- PopupRootAutomationPeer.cs
- ObjectIDGenerator.cs
- XamlGridLengthSerializer.cs
- AudioException.cs
- ListenerConstants.cs
- __Error.cs
- x509store.cs
- MenuStrip.cs
- Keyboard.cs
- FieldCollectionEditor.cs
- CssTextWriter.cs
- HitTestResult.cs
- CacheMemory.cs
- TextEditorLists.cs
- LoginView.cs
- WebEventCodes.cs
- InvalidDataException.cs
- QuaternionAnimation.cs
- ColumnMapTranslator.cs
- DataKeyArray.cs
- XmlSecureResolver.cs
- RemoteWebConfigurationHostServer.cs
- HuffModule.cs
- ListViewItem.cs
- DrawingImage.cs
- CryptoKeySecurity.cs
- CompensatableSequenceActivity.cs
- TerminateWorkflow.cs
- TabPanel.cs
- ObjectTypeMapping.cs
- xdrvalidator.cs
- SqlFunctions.cs
- SeverityFilter.cs
- DocumentProperties.cs
- LongAverageAggregationOperator.cs
- TransactionManager.cs
- TextLineBreak.cs
- SqlCommand.cs
- OdbcCommandBuilder.cs
- ExtenderProvidedPropertyAttribute.cs
- MSHTMLHostUtil.cs
- ArrangedElement.cs
- FlowLayoutPanel.cs
- IApplicationTrustManager.cs
- Aggregates.cs
- InheritedPropertyDescriptor.cs
- OutputCacheModule.cs
- DashStyles.cs
- HttpHeaderCollection.cs
- InvalidCommandTreeException.cs