示例#1
0
        /// <summary>
        /// Disposes this instance.
        /// </summary>
        public void Dispose()
        {
            var action = _context.TryGetAndUnset();

            if (action != null)
            {
                Task.Run(async() => await action.InvokeAsync());
            }
        }
示例#2
0
        /// <summary>
        /// On Dispose async
        /// </summary>
        protected override async ValueTask OnDisposeAsync()
        {
            var context = _context.TryGetAndUnset();

            if (context == null)
            {
                _slim.Wait();
                return;
            }

            try
            {
                await context.InvokeAsync();
            }
            finally
            {
                _slim.Set();
            }
        }