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
- FacetEnabledSchemaElement.cs
- EFDataModelProvider.cs
- MetaModel.cs
- MessageFilterException.cs
- SspiHelper.cs
- WebUtil.cs
- CaretElement.cs
- CodeCommentStatement.cs
- TextServicesDisplayAttribute.cs
- DataGridViewImageColumn.cs
- OleDbDataAdapter.cs
- SmiSettersStream.cs
- AttributeInfo.cs
- SqlTrackingQuery.cs
- ApplicationSecurityManager.cs
- MatrixTransform.cs
- RecognizerStateChangedEventArgs.cs
- HtmlInputCheckBox.cs
- GetPageCompletedEventArgs.cs
- DecodeHelper.cs
- WebServiceFault.cs
- BufferModesCollection.cs
- DocumentViewer.cs
- SqlFileStream.cs
- WebPartManager.cs
- counter.cs
- SchemaNamespaceManager.cs
- AsymmetricKeyExchangeFormatter.cs
- ReturnValue.cs
- DataBindEngine.cs
- AdornerDecorator.cs
- StdValidatorsAndConverters.cs
- NonDualMessageSecurityOverHttp.cs
- RayMeshGeometry3DHitTestResult.cs
- GridPattern.cs
- BindingCollection.cs
- Process.cs
- TableLayout.cs
- ModelPerspective.cs
- FormatterServices.cs
- WebControlToolBoxItem.cs
- SecUtil.cs
- ThreadAbortException.cs
- Int32Rect.cs
- UIElement.cs
- DesignTimeData.cs
- MustUnderstandSoapException.cs
- CustomAssemblyResolver.cs
- TemplateInstanceAttribute.cs
- XsltConvert.cs
- ColumnBinding.cs
- StrongTypingException.cs
- Accessible.cs
- XmlSortKeyAccumulator.cs
- DesignerAdapterUtil.cs
- DataSourceNameHandler.cs
- BuildTopDownAttribute.cs
- MarkupExtensionSerializer.cs
- Bitmap.cs
- CodeArrayIndexerExpression.cs
- DetailsViewPagerRow.cs
- MoveSizeWinEventHandler.cs
- TableRowGroupCollection.cs
- StringConverter.cs
- WebServiceHostFactory.cs
- DbDeleteCommandTree.cs
- BrushMappingModeValidation.cs
- RegistrationServices.cs
- URLString.cs
- IisTraceListener.cs
- UIElement.cs
- ApplicationServicesHostFactory.cs
- DriveInfo.cs
- RequestCachePolicy.cs
- StyleHelper.cs
- webproxy.cs
- x509store.cs
- MimeMapping.cs
- CornerRadiusConverter.cs
- AppDomainUnloadedException.cs
- ScrollProperties.cs
- RegistryPermission.cs
- ObjectDataSourceEventArgs.cs
- StrongNameUtility.cs
- Mappings.cs
- RoutingExtension.cs
- DataPagerField.cs
- CollaborationHelperFunctions.cs
- ScrollItemPatternIdentifiers.cs
- ImageCollectionEditor.cs
- RowUpdatedEventArgs.cs
- ThreadPool.cs
- Synchronization.cs
- EastAsianLunisolarCalendar.cs
- BitmapEditor.cs
- ThicknessAnimation.cs
- TimestampInformation.cs
- RegexGroupCollection.cs
- DLinqAssociationProvider.cs
- Vector3DConverter.cs