修改
This commit is contained in:
48
U8AppMain/MessageFilter.cs
Normal file
48
U8AppMain/MessageFilter.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace U8AppMain
|
||||
{
|
||||
public class MessageFilter : IMessageFilter
|
||||
{
|
||||
private Timer timer = new Timer();
|
||||
private int _lastTick = Environment.TickCount;
|
||||
|
||||
public MessageFilter(int closeInterval = 60)
|
||||
{
|
||||
this._closeInterval = closeInterval * 1000;
|
||||
this.timer.Interval = 10000;
|
||||
this.timer.Tick += Timer_Tick;
|
||||
this.timer.Start();
|
||||
}
|
||||
|
||||
|
||||
private int _closeInterval;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (Environment.TickCount - _closeInterval > Environment.TickCount)
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
if (m.Msg == (int)WindowsMessages.WM_MOUSEMOVE || m.Msg == (int)WindowsMessages.WM_KEYUP)
|
||||
{
|
||||
this._lastTick = Environment.TickCount;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user