public async Task ToggleControlsOfType <T>(Func <Task> action, HashSet <T> excludedControls = null) where T : Control { var controlQuery = new ControlBuilder <T>(_controls.OfType <T>()).ExcludeControls(excludedControls); try { controlQuery.Disable(); await action.Invoke(); } finally { controlQuery.Enable(); } }