using System.Timers;

namespace Pipette.Tool
{
    internal class TimerTool
    {
        public static void ScheduledTask(int interval, ElapsedEventHandler elapsed)
        {
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Enabled = true;
            timer.Interval = interval; //执行间隔时间,单位为毫秒; 这里实际间隔为10分钟  
            timer.Elapsed += elapsed;
            timer.Start();
        }
    }
}
TimerTool.ScheduledTask(1000, new ElapsedEventHandler((object source, ElapsedEventArgs e) =>
{
    System.Diagnostics.Debug.WriteLine("==IsAutoSave==" + IsAutoSave);
    if (IsAutoSave)
    {
        mTimerCount++;
        if (mTimerCount == int.Parse(intervals[IntervalIndex]))
        {
            SaveDeviceData();
            mTimerCount = 0;
        }
    }
}));