mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
Replace DelayInvoke with Task + Async
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
@@ -39,10 +40,10 @@ namespace Wox
|
||||
SpecialKeyState specialKeyState = GlobalHotkey.Instance.CheckModifiers();
|
||||
|
||||
var hotkeyModel = new HotkeyModel(
|
||||
specialKeyState.AltPressed,
|
||||
specialKeyState.ShiftPressed,
|
||||
specialKeyState.WinPressed,
|
||||
specialKeyState.CtrlPressed,
|
||||
specialKeyState.AltPressed,
|
||||
specialKeyState.ShiftPressed,
|
||||
specialKeyState.WinPressed,
|
||||
specialKeyState.CtrlPressed,
|
||||
key);
|
||||
|
||||
var hotkeyString = hotkeyModel.ToString();
|
||||
@@ -52,12 +53,11 @@ namespace Wox
|
||||
return;
|
||||
}
|
||||
|
||||
Dispatcher.DelayInvoke("HotkeyAvailabilityTest",
|
||||
() =>
|
||||
{
|
||||
SetHotkey(hotkeyModel);
|
||||
},
|
||||
TimeSpan.FromMilliseconds(500));
|
||||
Dispatcher.InvokeAsync(async () =>
|
||||
{
|
||||
await Task.Delay(500);
|
||||
SetHotkey(hotkeyModel);
|
||||
});
|
||||
}
|
||||
|
||||
public void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
|
||||
@@ -94,7 +94,7 @@ namespace Wox
|
||||
{
|
||||
try
|
||||
{
|
||||
HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", CurrentHotkey.CharKey, CurrentHotkey.ModifierKeys, (sender, e) => {});
|
||||
HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", CurrentHotkey.CharKey, CurrentHotkey.ModifierKeys, (sender, e) => { });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user