1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-05 02:34:07 +02:00

Replace the only remaining use of WindowsUtils.CreateSingleTickTimer

This commit is contained in:
chylex 2017-03-22 23:31:54 +01:00
parent fe5191d3b5
commit 342f74646e
2 changed files with 10 additions and 13 deletions
Core
Notification/Screenshot
Utils

View File

@ -1,6 +1,5 @@
using System;
using System.Windows.Forms;
using TweetDck.Core.Utils;
namespace TweetDck.Core.Notification.Screenshot{
sealed class TweetScreenshotManager : IDisposable{
@ -12,8 +11,16 @@ public TweetScreenshotManager(Form owner){
CanMoveWindow = () => false
};
this.timeout = WindowsUtils.CreateSingleTickTimer(10000);
this.timeout.Tick += (sender, args) => screenshot.Reset();
this.timeout = new Timer{
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){

View File

@ -5,7 +5,6 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using Timer = System.Windows.Forms.Timer;
namespace TweetDck.Core.Utils{
static class WindowsUtils{
@ -39,15 +38,6 @@ public static Process StartProcess(string file, string arguments, bool runElevat
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){
for(int waited = 0; waited < timeoutMillis; waited += timeStepMillis){
if (test()){