/// <summary> /// Disposes this instance. /// </summary> public void Dispose() { var action = _context.TryGetAndUnset(); if (action != null) { Task.Run(async() => await action.InvokeAsync()); } }
/// <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(); } }