IntroductionFirst of all, I would like to thank all of the readers who have read my previous articles. What a great support i have got from you people.I really felt great when binding navigator article was displayed on the dotprogramming page. Today we will learn, How to create Shutdown timer in c#
Design patternStep-1 : Add One timer control onto the winform. Also set two property
Step-2 : Add Two NumericUpDown control onto the form.
Code PatternStep-1 : Handle Timer_Tick Event . Copy this code and paste into your Timer_Tick event.
int a = DateTime.Now.Minute;
int b = DateTime.Now.Hour;
int c = Convert.ToInt32 (numericUpDown1.Value);
int d = Convert.ToInt32(numericUpDown2.Value);
if (a == d && b == c)
Process.Start("shutdown", "/s /t 0");
Note : Add System.Diagnostics namespace for Process class. Here DateTime class use 24 hour time , i want to tell you that your system watch display 8:20 PM.
Here DateTime Class represents Hour and minute. look like
8 pm (System watch) = 20 (According to DateTime class)
Code generate the following output