Take a look:
static Timer _timer = new Timer(5000);
public static void Main2(string[] args)
{
Program p = new Program();
_timer.Elapsed += OnTimedEvent;
new Thread(() =>
{
while (true)
{
Console.ReadLine();
_resetEvent.Set();
_timer.Stop();
}
}).Start();
p.getConsoleInput();
p.ReadWriteIntoFile();
p.WriteFileOutput();
}
private static ManualResetEvent _resetEvent = new ManualResetEvent(false);
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
{
_resetEvent.Set();
_timer.Stop();
}
public void WriteFileOutput()
{
string path = @"some path";
if (File.Exists(path))
{
string[] lines = File.ReadAllLines(path);
foreach (string line in lines)
{
Console.WriteLine(line);
}
}
_resetEvent.Reset();
_timer.Start();
_resetEvent.WaitOne();
}
If that is not what you need then please let me know
There are some advanced techniques in here. If you have any questions then post them as new ones so our friends in comments can pick up some points :)
Good luck ^_^