using System; using System.Threading.Tasks; namespace LibationUiBase; /// Await UI operations, report their failures, and always restore disabled controls. public static class LibraryOperation { public static async Task RunAsync(Func operation, Func reportError, Action? setControlsEnabled = null) { try { setControlsEnabled?.Invoke(false); await operation(); } catch (Exception ex) { await reportError(ex); } finally { setControlsEnabled?.Invoke(true); } } }