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
- SqlDataAdapter.cs
- CodeDelegateInvokeExpression.cs
- StorageRoot.cs
- SettingsBindableAttribute.cs
- InternalPermissions.cs
- WMIInterop.cs
- COM2ExtendedBrowsingHandler.cs
- HMACMD5.cs
- IResourceProvider.cs
- StoryFragments.cs
- FormatSettings.cs
- XPathAxisIterator.cs
- HtmlGenericControl.cs
- MetafileHeader.cs
- LocationUpdates.cs
- DropShadowBitmapEffect.cs
- TreeNodeCollectionEditor.cs
- Style.cs
- HtmlEncodedRawTextWriter.cs
- WorkflowInlining.cs
- RepeaterCommandEventArgs.cs
- ExceptionRoutedEventArgs.cs
- FixedTextPointer.cs
- WebPartManager.cs
- SocketException.cs
- SqlGenericUtil.cs
- ServicesUtilities.cs
- ActivityInfo.cs
- TextDecorationLocationValidation.cs
- VisualStyleTypesAndProperties.cs
- ReadOnlyState.cs
- GPPOINTF.cs
- AssertSection.cs
- ComponentGlyph.cs
- TraceSection.cs
- EntityProviderServices.cs
- MetadataHelper.cs
- DateTimeConstantAttribute.cs
- ComponentRenameEvent.cs
- EntityViewGenerationConstants.cs
- DrawingServices.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- TransformerTypeCollection.cs
- TextSearch.cs
- NameValueSectionHandler.cs
- ApplicationCommands.cs
- ContentFileHelper.cs
- ConfigurationPropertyAttribute.cs
- ThrowOnMultipleAssignment.cs
- SynchronizationScope.cs
- ActivityExecutionWorkItem.cs
- DebuggerService.cs
- SettingsPropertyValueCollection.cs
- TypeForwardedToAttribute.cs
- MenuItemStyle.cs
- X509CertificateClaimSet.cs
- TerminatorSinks.cs
- SQLDateTime.cs
- CredentialCache.cs
- WebBrowserEvent.cs
- CustomError.cs
- ObservableDictionary.cs
- EntityClassGenerator.cs
- ImplicitInputBrush.cs
- MenuRenderer.cs
- DispatcherObject.cs
- DBSchemaRow.cs
- SafeSecurityHelper.cs
- UIElementAutomationPeer.cs
- TemplateBindingExpressionConverter.cs
- UserNamePasswordValidationMode.cs
- CodeRegionDirective.cs
- GridSplitter.cs
- SafeEventLogWriteHandle.cs
- MethodBuilderInstantiation.cs
- ExpressionBindingCollection.cs
- ExpressionLexer.cs
- EncoderBestFitFallback.cs
- StopStoryboard.cs
- ToolStripItemImageRenderEventArgs.cs
- HttpServerProtocol.cs
- ProviderMetadata.cs
- HandlerBase.cs
- PaintValueEventArgs.cs
- DeclarativeExpressionConditionDeclaration.cs
- BoundField.cs
- TypeGeneratedEventArgs.cs
- KnownBoxes.cs
- _ShellExpression.cs
- LayoutDump.cs
- SymbolPair.cs
- Camera.cs
- TreeChangeInfo.cs
- PointHitTestParameters.cs
- BamlTreeNode.cs
- EventLogRecord.cs
- MemberRelationshipService.cs
- RootAction.cs
- CallbackCorrelationInitializer.cs
- SQLChars.cs