Search

Wednesday, February 5, 2014
0 comments

Make Shutdown timer in C# winforms

8:12 AMWednesday, February 5, 2014

Introduction

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;
Interval=1000

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

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top