Ejemplo n.º 1
0
        internal static void CheckCancellation <T>(T provider, CancellationToken token)
            where T : class
        {
#if DEBUG
            var c = (ITestableCancellableProvider)provider;
            c.CancelCounter++;

            if (c.CancelAfter != null)
            {
                if (c.CancelCounter >= c.CancelAfter)
                {
                    Throw.OperationCanceledException();
                }
            }
#endif
            token.ThrowIfCancellationRequested();
        }