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 the different ways a method can be overloaded?
Can int be null in c#?
How many types of constructors are there?
Give some examples for built in datatypes in c#?
What are c# i/o classes? What are the commonly used i/o classes?
What is the CTS, and how does it relate to the CLS?
What do you understand by 'access specifiers' in C#?
Why would you use untrusted verification?
What is difference between string and stringbuilder in c#?
What is the namespace for the thread class?
Define constructors
What is generic delegate in c#?
Structs are not reference types. Can structs have constructors?
What is the difference between namespace and class in c#?
What is the difference between method and function in c#?