Code:
/ 4.0 / 4.0 / 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. // ==++== // // 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
- xamlnodes.cs
- SemanticKeyElement.cs
- _DisconnectOverlappedAsyncResult.cs
- PointAnimation.cs
- ToolStripPanel.cs
- OAVariantLib.cs
- DocumentSequence.cs
- NonPrimarySelectionGlyph.cs
- TimersDescriptionAttribute.cs
- AdapterDictionary.cs
- TrackingProfileSerializer.cs
- CapabilitiesRule.cs
- BlurEffect.cs
- PropertyTabAttribute.cs
- StylusEditingBehavior.cs
- OracleLob.cs
- PageClientProxyGenerator.cs
- RuleSettings.cs
- ActionMismatchAddressingException.cs
- TdsValueSetter.cs
- ElasticEase.cs
- MILUtilities.cs
- SslStream.cs
- ISFTagAndGuidCache.cs
- RegexWorker.cs
- DrawingImage.cs
- DataGridLength.cs
- ScaleTransform.cs
- MissingManifestResourceException.cs
- ConsoleKeyInfo.cs
- TextAnchor.cs
- HtmlElementErrorEventArgs.cs
- XpsDocument.cs
- HostVisual.cs
- ExpressionPrefixAttribute.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- DataPointer.cs
- SignedXml.cs
- Exceptions.cs
- XMLSchema.cs
- TextSelectionHelper.cs
- SerializationSectionGroup.cs
- LayoutTableCell.cs
- X509CertificateClaimSet.cs
- CapabilitiesPattern.cs
- ValueHandle.cs
- ProcessInputEventArgs.cs
- Set.cs
- Events.cs
- ObjectStateEntry.cs
- UpdateDelegates.Generated.cs
- BidOverLoads.cs
- AvTrace.cs
- QilNode.cs
- PtsCache.cs
- SqlClientFactory.cs
- UpdateTracker.cs
- ToolStripControlHost.cs
- PasswordBoxAutomationPeer.cs
- XmlIlVisitor.cs
- ScrollContentPresenter.cs
- PrivacyNoticeBindingElementImporter.cs
- MobileListItem.cs
- SiteMap.cs
- QueryCacheEntry.cs
- PartitionedStreamMerger.cs
- CLRBindingWorker.cs
- DocumentViewerConstants.cs
- _NetRes.cs
- GeometryCombineModeValidation.cs
- WebPartDisplayMode.cs
- SystemFonts.cs
- EventEntry.cs
- AdornerLayer.cs
- ConstrainedGroup.cs
- SaveFileDialog.cs
- FixedStringLookup.cs
- SchemeSettingElement.cs
- ConnectionPoint.cs
- HWStack.cs
- LinqDataSourceView.cs
- OpCopier.cs
- SpellerStatusTable.cs
- DataGridViewLinkColumn.cs
- ToolStripItemImageRenderEventArgs.cs
- VariableQuery.cs
- CompilationLock.cs
- PeerInvitationResponse.cs
- HtmlEmptyTagControlBuilder.cs
- SafeLibraryHandle.cs
- ByteStreamGeometryContext.cs
- OracleLob.cs
- DataSourceGroupCollection.cs
- COAUTHINFO.cs
- _OSSOCK.cs
- DefaultShape.cs
- MultipartContentParser.cs
- Utils.cs
- AlignmentYValidation.cs
- Decoder.cs