#region 内存回收
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
/// <summary>
/// 释放内存
/// </summary>
public static void ClearMemory()
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
App.SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
}
}
#endregion
public static System.Timers.Timer t;
Thread thread = new Thread(new ThreadStart(Timer));
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
public void Timer()
{
t = new System.Timers.Timer();
t.Interval = 10000;
t.Elapsed += new System.Timers.ElapsedEventHandler(OpenCheck);//到达时间的时候执行事件;
t.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
}
public void OpenCheck(object source, System.Timers.ElapsedEventArgs e)