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
- XmlLangPropertyAttribute.cs
- ArrangedElement.cs
- ListViewPagedDataSource.cs
- ISessionStateStore.cs
- DetailsViewUpdatedEventArgs.cs
- IISUnsafeMethods.cs
- ByteAnimation.cs
- ItemCheckEvent.cs
- ActivityExecutor.cs
- TextWriter.cs
- ProcessModelInfo.cs
- codemethodreferenceexpression.cs
- CornerRadiusConverter.cs
- Automation.cs
- PreviewPageInfo.cs
- HtmlElementCollection.cs
- Image.cs
- ReservationNotFoundException.cs
- LogRestartAreaEnumerator.cs
- DelegateBodyWriter.cs
- SetStoryboardSpeedRatio.cs
- InputReportEventArgs.cs
- OletxDependentTransaction.cs
- WithStatement.cs
- RootBrowserWindowProxy.cs
- TextServicesContext.cs
- UIElementParaClient.cs
- ZipIOExtraField.cs
- login.cs
- DragEventArgs.cs
- UpDownBase.cs
- FormViewInsertedEventArgs.cs
- MailWebEventProvider.cs
- SqlDataSourceView.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- Multiply.cs
- Cursors.cs
- BinaryConverter.cs
- SrgsElementList.cs
- filewebresponse.cs
- EncoderParameters.cs
- SamlAttribute.cs
- UIElement3D.cs
- EdmItemCollection.cs
- UdpDiscoveryEndpoint.cs
- FreezableCollection.cs
- QueryRewriter.cs
- BrowsableAttribute.cs
- DBCommand.cs
- EditableRegion.cs
- LowerCaseStringConverter.cs
- ObjectListSelectEventArgs.cs
- WpfKnownType.cs
- HttpConfigurationContext.cs
- FormatterConverter.cs
- ErrorTableItemStyle.cs
- WebMessageEncoderFactory.cs
- MailBnfHelper.cs
- RangeExpression.cs
- DynamicUpdateCommand.cs
- CodeNamespaceImport.cs
- TraceSwitch.cs
- WinEventTracker.cs
- RijndaelManagedTransform.cs
- TypeUtils.cs
- OracleCommandBuilder.cs
- TableDetailsCollection.cs
- ConnectionsZone.cs
- Label.cs
- TextRange.cs
- WaitHandleCannotBeOpenedException.cs
- TextBox.cs
- DesignerLoader.cs
- login.cs
- SqlConnectionPoolProviderInfo.cs
- Run.cs
- VirtualPathProvider.cs
- MemberExpressionHelper.cs
- AssociationSetEnd.cs
- LocalServiceSecuritySettings.cs
- SpeakProgressEventArgs.cs
- PropertyCollection.cs
- WebPartCloseVerb.cs
- RegexFCD.cs
- ComponentEditorPage.cs
- TextStore.cs
- TdsParserSessionPool.cs
- D3DImage.cs
- ViewCellSlot.cs
- GZipDecoder.cs
- DynamicActivityProperty.cs
- Matrix3D.cs
- ItemsControlAutomationPeer.cs
- MediaContext.cs
- RestClientProxyHandler.cs
- FilterQuery.cs
- HostingEnvironmentSection.cs
- PermissionSetTriple.cs
- TogglePattern.cs
- SrgsElementFactoryCompiler.cs