mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
Fix UI issues when using web search plugin with suggestions
This commit is contained in:
43
Plugins/Wox.Plugin.WebSearch/EasyTimer.cs
Normal file
43
Plugins/Wox.Plugin.WebSearch/EasyTimer.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Plugin.WebSearch
|
||||
{
|
||||
public static class EasyTimer
|
||||
{
|
||||
public static IDisposable SetInterval(Action method, int delayInMilliseconds)
|
||||
{
|
||||
System.Timers.Timer timer = new System.Timers.Timer(delayInMilliseconds);
|
||||
timer.Elapsed += (source, e) =>
|
||||
{
|
||||
method();
|
||||
};
|
||||
|
||||
timer.Enabled = true;
|
||||
timer.Start();
|
||||
|
||||
// Returns a stop handle which can be used for stopping
|
||||
// the timer, if required
|
||||
return timer as IDisposable;
|
||||
}
|
||||
|
||||
public static IDisposable SetTimeout(Action method, int delayInMilliseconds)
|
||||
{
|
||||
System.Timers.Timer timer = new System.Timers.Timer(delayInMilliseconds);
|
||||
timer.Elapsed += (source, e) =>
|
||||
{
|
||||
method();
|
||||
};
|
||||
|
||||
timer.AutoReset = false;
|
||||
timer.Enabled = true;
|
||||
timer.Start();
|
||||
|
||||
// Returns a stop handle which can be used for stopping
|
||||
// the timer, if required
|
||||
return timer as IDisposable;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user