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
- ListParaClient.cs
- DriveNotFoundException.cs
- DirtyTextRange.cs
- CommandField.cs
- SchemaObjectWriter.cs
- CopyNodeSetAction.cs
- VariantWrapper.cs
- DataListItemCollection.cs
- FormattedTextSymbols.cs
- OleDbCommand.cs
- EntityClassGenerator.cs
- PartialCachingControl.cs
- Component.cs
- XmlRootAttribute.cs
- HtmlShim.cs
- XmlNullResolver.cs
- WindowsSlider.cs
- HttpListenerRequestUriBuilder.cs
- FileSystemInfo.cs
- TraceContext.cs
- ColumnResizeAdorner.cs
- NextPreviousPagerField.cs
- WebPartConnectionsConnectVerb.cs
- MappedMetaModel.cs
- OpCellTreeNode.cs
- InfoCardRSACryptoProvider.cs
- DataGridHeadersVisibilityToVisibilityConverter.cs
- XhtmlConformanceSection.cs
- NativeMethods.cs
- TemplateControlParser.cs
- Rectangle.cs
- SafeLibraryHandle.cs
- NativeMethodsCLR.cs
- OperandQuery.cs
- FolderLevelBuildProvider.cs
- DataGridItemCollection.cs
- CaseCqlBlock.cs
- Control.cs
- TableLayoutPanel.cs
- TableLayoutPanelCellPosition.cs
- SqlTransaction.cs
- SqlCacheDependency.cs
- SingleObjectCollection.cs
- BinaryFormatter.cs
- UniqueConstraint.cs
- ContextMenuAutomationPeer.cs
- WorkflowViewStateService.cs
- HttpPostServerProtocol.cs
- TargetFrameworkAttribute.cs
- SafeCryptoHandles.cs
- HttpDebugHandler.cs
- ApplicationId.cs
- MimeBasePart.cs
- ByteStreamBufferedMessageData.cs
- MatrixTransform3D.cs
- unitconverter.cs
- XsdDateTime.cs
- HashRepartitionStream.cs
- ObjectMemberMapping.cs
- MSAANativeProvider.cs
- ToolStripKeyboardHandlingService.cs
- MembershipSection.cs
- QueryOpeningEnumerator.cs
- Content.cs
- WSTrust.cs
- ConnectionProviderAttribute.cs
- TreeViewCancelEvent.cs
- UserControlDocumentDesigner.cs
- TextServicesCompartmentContext.cs
- SqlReorderer.cs
- Operand.cs
- ISO2022Encoding.cs
- SetIterators.cs
- ThrowHelper.cs
- TextEditorLists.cs
- PtsPage.cs
- OrderByQueryOptionExpression.cs
- ElementHostPropertyMap.cs
- SessionPageStatePersister.cs
- XmlSchemaAttributeGroupRef.cs
- XmlAttributeHolder.cs
- PeerToPeerException.cs
- RelationshipConverter.cs
- InvariantComparer.cs
- InfoCardProofToken.cs
- DetailsViewRow.cs
- Stroke2.cs
- PackageRelationshipSelector.cs
- HtmlElement.cs
- PenThreadWorker.cs
- DesignTimeVisibleAttribute.cs
- Evidence.cs
- SectionInformation.cs
- _TLSstream.cs
- SqlMethodTransformer.cs
- FontDifferentiator.cs
- OuterGlowBitmapEffect.cs
- TableLayoutStyleCollection.cs
- TextBreakpoint.cs
- ZipIOCentralDirectoryFileHeader.cs