Ejemplo n.º 1
0
        public async Task InvokeAsync(ActionExecutingContext context)
        {
            await using ThrottlingFunc ra = new ThrottlingFunc(_callbackThrottlingInterval);
            var rawAction = context.Callback;

            context.Callback = async o =>
            {
                if (rawAction == null)
                {
                    return;
                }

                try
                {
                    // ReSharper disable once AccessToDisposedClosure
                    await ra.PostAsync(() => rawAction(o));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                // ReSharper disable once AccessToDisposedClosure
            };
            await _next(context);
        }
Ejemplo n.º 2
0
        public async Task InvokeAsync(ActionExecutingContext context)
        {
#if NETSTANDARD2_1 || NETCOREAPP3_1
            await
#endif
            using var ra = new ThrottlingFunc(_callbackThrottlingInterval);

            var rawAction = context.Callback;
            context.Callback = async o =>
            {
                try
                {
                    await ra.PostAsync(() => rawAction(o));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                // ReSharper disable once AccessToDisposedClosure
            };
            await _next(context);
        }