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
What are some of the commonly used commands in sqlcommand?
How to implement singleton design pattern in c#?
What is the difference between class and namespace?
What is difference between managed and unmanaged code?
How do you access a constant field declared in a class?
what are implementation inheritance and interface inheritance?
When is a class declared as a class abstract?
What is strong name assembly?
what is the purpose of using statement in c#
How is a loop recorder monitored?
What is a satellite assembly in c#?
Which of the following API is used to hide a window?
List some Advantages of switch-case over if else?
What is the difference between a constant and a static readonly field?
Difference between call by value and call by reference in C#?