C # delay function

Problem: The interface is suspended

Solution: use the delay function

When it comes to delay, the most likely thing to think of is sleep. There is a problem here. Sleep will cause the interface to die, and a delay function is needed here.

Paste code

        public static void Delay(Int32 DateTimes)
        {
            DateTime curr = DateTime.Now;
            while (curr.AddMilliseconds(DateTimes) > DateTime.Now)
            {
                Application.DoEvents();
            }
            return;
        }
View Code

 

Guess you like

Origin www.cnblogs.com/qixiaolan/p/12737307.html