1, add to Timer control , This control can display the countdown function

2,Timer Control's Tick Event code :
private void timerDownCount_Tick(object sender, EventArgs e) { string
dateDiff = null; // Get the current time DateTime DateTime1 = DateTime.Now; // The next day 00 spot 00 branch 00 second
DateTime DateTime2 = DateTime.Now.AddDays(1).Date; // How many seconds is the difference int sec =
(int)DateTime2.Subtract(DateTime1).TotalSeconds; if (sec == 0) {
// delay 1 Second execution ( Why delay ? If not delayed , At the moment of restart, the time difference between the two is still the same 0, It will trigger a restart again ) Thread.Sleep(1000);
//-------------- Restart the software start--------------- // Open a new instance
Process.Start(Application.ExecutablePath); // Close the current instance
Process.GetCurrentProcess().Kill(); //-------------- Restart the software end----------------- }
if (sec < 0) { this.timerDownCount.Stop(); } else { // hold 2 Turn it into TimeSpan, Convenient calculation
TimeSpan ts1 = new TimeSpan(DateTime1.Ticks); TimeSpan ts2 = new
TimeSpan(DateTime2.Ticks); // Time comparison , Get the difference TimeSpan ts =
ts1.Subtract(ts2).Duration(); // result dateDiff = ts.Hours.ToString() + " hour " +
ts.Minutes.ToString() + " minute " + ts.Seconds.ToString() + " second ";
this.labDownCount.Text = dateDiff; } }
 

Technology
©2020 ioDraw All rights reserved
Vue The difference between single page and multi page 0.96OLED display -4 Line SPI explain R In language Axis() Detailed explanation of function parameters JAVA Snake games ( Source code + notes )C++ vector Simulation Implementation of class javascript Adding and deleting form information CCF A series of questions --2016 year 4 Month 1 Calculation of break point postman Interface test get timestamp and MD5 encryption 【 Recommended benefits 】c++ use easyx Making pixel birds , Simple hands on games TCP/IP There are so many loopholes in the agreement ?