I have created a console application in C# and there is main method (static) and my requirement is to initialize 2 timers and handles 2 methods respectively which will be called periodically to do some task. Now I have taken all other methods/variables static because that are calling from timer handler events (which are static due to calling it from main).
Now i would like to know for above scenario how memory is going to be consumed if this console running for long time? if i would like to apply oops concept then do i need make all methods/variables non static and access that by creating object of class? in this case how memory going to be consume?
Update: Following is snippet of my code
public class Program
{
readonly static Timer timer = new Timer();
static DateTime currentDateTime;
//other static variables
//-----
static void Main()
{
timer.Interval = 1000 * 5;
timer.AutoReset = true;
timer.Enabled = true;
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Start();
//2nd timer
//-----
System.Console.ReadKey();
timer.Stop();
}
static void timer_Elapsed(object sender, ElapsedEventArgs e)
{
currentDateTime = DateTime.UtcNow;
PushData();
}
private static void PushData()
{
//Code to push data
}
}