How to run the program at particular time? It should run
everyday at 3:00 PM. After executing the program should
sleep until next day at 3:00 PM. Please explain with code?

Answer Posted / renu

Here is the code that you expected.

public static void Main()
{
Timer timer = new Timer();
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
timer.Interval = Convert.ToDouble
(ConfigurationManager.AppSettings["TimerInterval"]) * 1000;
timer.Enabled = true;
}
private void OnElapsedTime(object source, ElapsedEventArgs
e)
{
timer.Enabled = false;
//Call your business logic here
timer.Enabled = true;
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain polymorphism in c# with a simple example?

513


Tell me the difference between call by value and call by reference.

536


How to override a function in c#?

540


What is interface c#?

455


What are verbatim strings in c#?

493






What is the meaning of extention?

480


Explain the different types of delegates used in c#.

507


What is the difference between protected and private?

465


How is exception handling implemented in c#?

577


Explain how do you directly call a native function exported from a dll?

505


Why we use get and set property in c#?

513


What is the default value of boolean variable?

454


How do you implement thread synchronization (object.wait, notify,and criticalsection) in c#?

619


Define sealed classes in c#?

511


What is cosole application?

570