/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/settings-ui/Settings.UI/Helpers/AsyncCommand.cs
42 строки
1 KB
moooyo
[AOT] clean up AOT issue in Settings.UI (#36559)
24 фев 2025, 21:48
Не верифицирован
24 фев 2025, 21:48
f81f65d
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; namespace Microsoft.PowerToys.Settings.UI.Helpers { internal sealed partial class AsyncCommand : ICommand { private readonly Func<Task> _execute; private readonly Func<bool> _canExecute; public event EventHandler CanExecuteChanged; public AsyncCommand(Func<Task> execute, Func<bool> canExecute = null) { _execute = execute; _canExecute = canExecute; } public bool CanExecute(object parameter) { return _canExecute == null || _canExecute(); } public async void Execute(object parameter) { await _execute(); } public void RaiseCanExecuteChanged() { CanExecuteChanged?.Invoke(this, EventArgs.Empty); } } }