diff --git a/Wox/Helper/DispatcherExtensions.cs b/Wox/Helper/DispatcherExtensions.cs index 2ea304a2ed..a2f5643ea6 100644 --- a/Wox/Helper/DispatcherExtensions.cs +++ b/Wox/Helper/DispatcherExtensions.cs @@ -12,20 +12,13 @@ namespace Wox new Dictionary(); private static readonly object syncRoot = new object(); - public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation, - Action action, TimeSpan delay, - DispatcherPriority priority = DispatcherPriority.Normal) - { - return DelayInvoke(dispatcher, namedInvocation, action, delay, string.Empty, priority); - } - - public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation, - Action action, TimeSpan delay, string arg, + public static void DelayInvoke(this Dispatcher dispatcher, string namedInvocation, + Action action, TimeSpan delay, DispatcherPriority priority = DispatcherPriority.Normal) { lock (syncRoot) { - if (String.IsNullOrEmpty(namedInvocation)) + if (string.IsNullOrEmpty(namedInvocation)) { namedInvocation = Guid.NewGuid().ToString(); } @@ -36,11 +29,10 @@ namespace Wox var timer = new DispatcherTimer(delay, priority, (s, e) => { RemoveTimer(namedInvocation); - action(arg); + action(); }, dispatcher); timer.Start(); timers.Add(namedInvocation, timer); - return namedInvocation; } } diff --git a/Wox/HotkeyControl.xaml.cs b/Wox/HotkeyControl.xaml.cs index 135769c743..783e3e59da 100644 --- a/Wox/HotkeyControl.xaml.cs +++ b/Wox/HotkeyControl.xaml.cs @@ -53,7 +53,7 @@ namespace Wox } Dispatcher.DelayInvoke("HotkeyAvailabilityTest", - o => + () => { SetHotkey(hotkeyModel); }, diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 80dc021829..3969505890 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -457,27 +457,27 @@ namespace Wox int searchDelay = GetSearchDelay(lastQuery); Dispatcher.DelayInvoke("UpdateSearch", - o => + () => { - Dispatcher.DelayInvoke("ClearResults", i => + Dispatcher.DelayInvoke("ClearResults", () => { // first try to use clear method inside pnlResult, which is more closer to the add new results // and this will not bring splash issues.After waiting 100ms, if there still no results added, we // must clear the result. otherwise, it will be confused why the query changed, but the results // didn't. if (pnlResult.Dirty) pnlResult.Clear(); - }, TimeSpan.FromMilliseconds(100), null); + }, TimeSpan.FromMilliseconds(100)); queryHasReturn = false; Query query = new Query(lastQuery); query.IsIntantQuery = searchDelay == 0; Query(query); - Dispatcher.DelayInvoke("ShowProgressbar", originQuery => + Dispatcher.DelayInvoke("ShowProgressbar", () => { - if (!queryHasReturn && originQuery == tbQuery.Text && !string.IsNullOrEmpty(lastQuery)) + if (!queryHasReturn && !string.IsNullOrEmpty(lastQuery)) { StartProgress(); } - }, TimeSpan.FromMilliseconds(150), tbQuery.Text); + }, TimeSpan.FromMilliseconds(150)); //reset query history index after user start new query ResetQueryHistoryIndex(); }, TimeSpan.FromMilliseconds(searchDelay)); diff --git a/Wox/Msg.xaml.cs b/Wox/Msg.xaml.cs index 9f9801cf30..3fb7b89b8f 100644 --- a/Wox/Msg.xaml.cs +++ b/Wox/Msg.xaml.cs @@ -71,11 +71,11 @@ namespace Wox { Show(); Dispatcher.DelayInvoke("ShowMsg", - o => { - if (!closing) { - closing = true; - Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin)); - } + () => { + if (!closing) { + closing = true; + Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin)); + } }, TimeSpan.FromSeconds(3)); } } diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs index eec796d99d..576ef4d7f7 100644 --- a/Wox/ResultPanel.xaml.cs +++ b/Wox/ResultPanel.xaml.cs @@ -225,7 +225,7 @@ namespace Wox if (e.AddedItems.Count > 0 && e.AddedItems[0] != null) { lbResults.ScrollIntoView(e.AddedItems[0]); - Dispatcher.DelayInvoke("UpdateItemNumber", o => + Dispatcher.DelayInvoke("UpdateItemNumber", () => { UpdateItemNumber(); }, TimeSpan.FromMilliseconds(3)); diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 5520b4c534..603d4712a2 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -464,7 +464,7 @@ namespace Wox private void DelayChangeTheme() { - Dispatcher.DelayInvoke("delayChangeTheme", o => + Dispatcher.DelayInvoke("delayChangeTheme", () => { ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme); }, TimeSpan.FromMilliseconds(100));