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
- HostedHttpContext.cs
- ThrowHelper.cs
- AsyncOperation.cs
- Attributes.cs
- XmlUrlResolver.cs
- Canvas.cs
- StorageEntitySetMapping.cs
- DeclarationUpdate.cs
- KeyEventArgs.cs
- DiscardableAttribute.cs
- DataServiceQueryOfT.cs
- ReflectionTypeLoadException.cs
- DataReaderContainer.cs
- TableRowGroup.cs
- WSFederationHttpSecurityElement.cs
- FieldToken.cs
- Point.cs
- FastPropertyAccessor.cs
- DesignerProperties.cs
- ParserHooks.cs
- MachineKeyValidationConverter.cs
- OleDbDataAdapter.cs
- ColumnWidthChangingEvent.cs
- ContentPlaceHolderDesigner.cs
- ButtonChrome.cs
- OutputScopeManager.cs
- WebZone.cs
- FixUp.cs
- DataTablePropertyDescriptor.cs
- ServiceProviders.cs
- elementinformation.cs
- ToolboxCategory.cs
- TextTreeUndo.cs
- CapabilitiesState.cs
- PrimaryKeyTypeConverter.cs
- TransformerTypeCollection.cs
- CodeTypeDeclarationCollection.cs
- SqlDataSourceStatusEventArgs.cs
- XmlSchemaSearchPattern.cs
- followingsibling.cs
- InputMethodStateTypeInfo.cs
- SqlConnectionFactory.cs
- SiteMapHierarchicalDataSourceView.cs
- Renderer.cs
- WebBrowserSiteBase.cs
- PeerResolverMode.cs
- BindValidator.cs
- OrthographicCamera.cs
- LoadMessageLogger.cs
- _MultipleConnectAsync.cs
- RegexInterpreter.cs
- ButtonDesigner.cs
- QilExpression.cs
- SqlParameterCollection.cs
- XhtmlBasicControlAdapter.cs
- CreatingCookieEventArgs.cs
- UnmanagedBitmapWrapper.cs
- ArcSegment.cs
- DispatcherOperation.cs
- Aggregates.cs
- VisualBasicReference.cs
- TypeDependencyAttribute.cs
- Unit.cs
- FileAccessException.cs
- XslNumber.cs
- HtmlTernaryTree.cs
- CompositeFontFamily.cs
- ListManagerBindingsCollection.cs
- ReaderContextStackData.cs
- Point3DCollection.cs
- BinHexEncoder.cs
- PackWebRequest.cs
- CodeSnippetExpression.cs
- XsdBuildProvider.cs
- DataGridViewRow.cs
- DataGridClipboardCellContent.cs
- ObjectDataSourceDisposingEventArgs.cs
- _LocalDataStore.cs
- BuildProvidersCompiler.cs
- DrawingImage.cs
- HGlobalSafeHandle.cs
- WebSysDescriptionAttribute.cs
- FolderNameEditor.cs
- Collection.cs
- DataErrorValidationRule.cs
- GlyphRun.cs
- FileSystemWatcher.cs
- StylusPlugInCollection.cs
- updatecommandorderer.cs
- StringSorter.cs
- MimeObjectFactory.cs
- StrokeNodeEnumerator.cs
- HuffCodec.cs
- _AcceptOverlappedAsyncResult.cs
- EventManager.cs
- ConcatQueryOperator.cs
- WriteLine.cs
- DataBindingCollection.cs
- contentDescriptor.cs
- WebScriptEndpoint.cs