using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace YQLUtils
{
    public class AppTimeLoop
    {
        public static void ProcessEvents(int interVal)
        {
            int waittime       = 2;
            DateTime startTime = DateTime.Now;
            while(true)
            {
                DateTime endTime = DateTime.Now;
                if ((int)(endTime - startTime).TotalMilliseconds >= interVal)
                    break;
                Thread.Sleep(waittime);
            }
        }
        public static void delay(int interVal)
        {
            if (interVal == 0)
                return;
            Thread.Sleep(Math.Abs(interVal));
        }
        public static void msleep(int interVal)
        {
            if (interVal == 0)
                return;
            Thread.Sleep(Math.Abs(interVal));
        }
        public static void sleep(int interVal)
        {
            if (interVal == 0)
                return;
            Thread.Sleep(Math.Abs(interVal * 1000));
        }
    }
}
