💥 集成everything 开发
This commit is contained in:
34
Util/DelayHelper.cs
Normal file
34
Util/DelayHelper.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class DelayHelper
|
||||
{
|
||||
public event EventHandler Idled = delegate { };
|
||||
public int WaitingMilliSeconds { get; set; }
|
||||
|
||||
public object Source { get; set; }
|
||||
|
||||
readonly System.Threading.Timer waitingTimer;
|
||||
|
||||
public DelayHelper(int waitingMilliSeconds = 600)
|
||||
{
|
||||
WaitingMilliSeconds = waitingMilliSeconds;
|
||||
waitingTimer = new System.Threading.Timer(p =>
|
||||
{
|
||||
Idled(this, EventArgs.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void DelayExecute(object source)
|
||||
{
|
||||
this.Source = source;
|
||||
waitingTimer.Change(WaitingMilliSeconds, System.Threading.Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user