mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-06-12 17:34:09 +02:00
Replace the only remaining use of WindowsUtils.CreateSingleTickTimer
This commit is contained in:
parent
fe5191d3b5
commit
342f74646e
Core
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using TweetDck.Core.Utils;
|
|
||||||
|
|
||||||
namespace TweetDck.Core.Notification.Screenshot{
|
namespace TweetDck.Core.Notification.Screenshot{
|
||||||
sealed class TweetScreenshotManager : IDisposable{
|
sealed class TweetScreenshotManager : IDisposable{
|
||||||
@ -12,8 +11,16 @@ public TweetScreenshotManager(Form owner){
|
|||||||
CanMoveWindow = () => false
|
CanMoveWindow = () => false
|
||||||
};
|
};
|
||||||
|
|
||||||
this.timeout = WindowsUtils.CreateSingleTickTimer(10000);
|
this.timeout = new Timer{
|
||||||
this.timeout.Tick += (sender, args) => screenshot.Reset();
|
Interval = 10000
|
||||||
|
};
|
||||||
|
|
||||||
|
this.timeout.Tick += timeout_Tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timeout_Tick(object sender, EventArgs e){
|
||||||
|
timeout.Stop();
|
||||||
|
screenshot.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Trigger(string html, int width, int height){
|
public void Trigger(string html, int width, int height){
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Timer = System.Windows.Forms.Timer;
|
|
||||||
|
|
||||||
namespace TweetDck.Core.Utils{
|
namespace TweetDck.Core.Utils{
|
||||||
static class WindowsUtils{
|
static class WindowsUtils{
|
||||||
@ -39,15 +38,6 @@ public static Process StartProcess(string file, string arguments, bool runElevat
|
|||||||
return Process.Start(processInfo);
|
return Process.Start(processInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Timer CreateSingleTickTimer(int timeout){
|
|
||||||
Timer timer = new Timer{
|
|
||||||
Interval = timeout
|
|
||||||
};
|
|
||||||
|
|
||||||
timer.Tick += (sender, args) => timer.Stop();
|
|
||||||
return timer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TrySleepUntil(Func<bool> test, int timeoutMillis, int timeStepMillis){
|
public static bool TrySleepUntil(Func<bool> test, int timeoutMillis, int timeStepMillis){
|
||||||
for(int waited = 0; waited < timeoutMillis; waited += timeStepMillis){
|
for(int waited = 0; waited < timeoutMillis; waited += timeStepMillis){
|
||||||
if (test()){
|
if (test()){
|
||||||
|
Loading…
Reference in New Issue
Block a user