Make Shutdown timer in C# winforms

February 05, 2014 0 Comments


First 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 pattern

Step-1 : Add One timer control onto the winform. Also set two property

Enabled =True;

Step-2 : Add Two NumericUpDown control onto the form.

Code Pattern

Step-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
Make Shutdown timer in C# winforms

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google