2
Reply

C# Countdown for 1 Year

Shafiqq Aziz

Shafiqq Aziz

Nov 15 2017 3:05 AM
136
Hi, is there any possibility to create a countdown for 1 year and disable login for windows form?
 
The countdown will not stop if the user logout the app or shutdown their PC.
  1. int OrigTime = 1800;  
  2.   
  3. private void button1_Click(object sender, EventArgs e)  
  4.    {  
  5.        Timer timeX = new Timer();  
  6.        timeX.Interval = 1800000;  
  7.        timeX.Tick += new EventHandler(timeX_Tick);  
  8.    }  
  9.   
  10. private void timeX_Tick(object sender, EventArgs e)  
  11.    {  
  12.        OrigTime--;  
  13.        textBox1.Text = OrigTime/60 + ":" + ((OrigTime % 60) >= 10 ?  (OrigTime % 60).ToString() : "0" + OrigTime % 60);  
  14.    }  
The code above is triggered when user click a button and will stop automatically. 

Answers (2)