Results 1 to 6 of 6

Thread: how timer work in c#

  1. #1
    Join Date
    Jul 2009
    Posts
    1,118

    how timer work in c#

    hi ,
    i am student.Now i am learning a programming language which is c#, In that programming language,there is some timer function.Actually i don't understand how timer function support to c# program.What is the main role of timer in c# .So any one tell me what is the relation of timer & c#

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: how timer work in c#

    C# (sharp) is a object oriented , component oriented programming language. It was developed by Microsoft.Timer is work like clock. You can also use timer as controller the sequence of process.In c# programming language, timer set a time interval to execute the process,if you want execute any particular application after particular interval,then you can use the timer option.you can also use as backup means if you want to create a backup file of your data processing in every hour that time you can also use the timer.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: how timer work in c#

    C# is a programming language ,in coding part Timer_Event will active only after the Timer.Start()method is called.We want to set the interval between Timer_Event that time interval property is used,after disabling the timer or stop() method apply then timer will be stop.When you create a project that work lots of time duration,so you can also create the time class due to you can calculate the whole time during project you can also convert times from and to other data types.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: how timer work in c#

    In c# programming there are time & date option available for showing the time & date.But rather than the better way to present date & time on
    screen which is through timer option.A timer allows a process -in the form of a delegate to be called at a certain time or after certain time passed. There are timer name space available in system.There are numerous way to use timer function.This timer is used to display the time on screen & for backup the routine time .You could create a timer ,which fires off a program at a given time.You can also create the backup type of timer where it copy the important data at a given time interval.you can also create a timer where it log off a user at given time period.so there are so many benefits of timer option in c# programming language.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: how timer work in c#

    There are three type of timer available which is Server Timers, Windows Timers, and Thread Timers.The most important timer which is server - based timer is a an update of the traditional timer that has optimized to run in server environment.The thread timer is a simple ,lightweight timer that are uses callback method instead of event.Timer is work like a clock in programming system. so due to timer you can easily operate the date & time function in system.

  6. #6
    softtrickseo Guest

    Re: how timer work in c#

    method is called. Interval property is used to set the interval between Timer_Event. Timer can be stopped either by disabling the Timer or calling the Stop() method.
    here is a small example :
    using System;
    using System.Windows.Forms;
    using System.Drawing;

    class TimerDemo:Form
    {
    Timer Clock;
    Label lbTime=new Label();

    public TimerDemo()
    {
    Clock=new Timer();
    Clock.Interval=1000;
    Clock.Start();
    Clock.Tick+=new EventHandler(Timer_Tick);

    this.Controls.Add(lbTime);
    lbTime.BackColor=Color.Black;
    lbTime.ForeColor=Color.Red;
    lbTime.Font=new Font("Times New Roman",15);
    lbTime.Text=GetTime();
    }

    public string GetTime()
    {
    string TimeInString="";
    int hour=DateTime.Now.Hour;
    int min=DateTime.Now.Minute;
    int sec=DateTime.Now.Second;

    TimeInString=(hour < 10)?"0" + hour.ToString() :hour.ToString();
    TimeInString+=":" + ((min<10)?"0" + min.ToString() :min.ToString());
    TimeInString+=":" + ((sec<10)?"0" + sec.ToString() :sec.ToString());
    return TimeInString;
    }

    public void Timer_Tick(object sender,EventArgs eArgs)
    {
    if(sender==Clock)
    {
    lbTime.Text=GetTime();
    }
    }

    public static void Main()
    {
    Application.Run(new TimerDemo());
    }
    }

Similar Threads

  1. Sleep timer won't work in MacBook
    By Asvin in forum Portable Devices
    Replies: 6
    Last Post: 25-04-2012, 05:15 AM
  2. Add Timer in c#
    By JasonWung in forum Software Development
    Replies: 1
    Last Post: 18-04-2012, 06:21 PM
  3. Sharepoint (MOSS) timer jobs and the timer service
    By MahaGuru in forum Office Setup
    Replies: 2
    Last Post: 01-03-2011, 09:08 AM
  4. PHP Wait timer?
    By Angelica Maria in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 12:13 PM
  5. Shutdown Your PC With a Timer
    By Aadi in forum Guides & Tutorials
    Replies: 5
    Last Post: 11-10-2008, 06:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,718,433,018.96278 seconds with 17 queries