Check log every 5 min in C#

July 15, 2008

where timerticlickvoid is the click of the timer….

public void timertickvoid()
{
// Set the timer interval to 5 minutes
timerCheck.Interval = (int)(5 * 1000 * 60);

FileStream fs = File.OpenRead(”timer.log”);
StreamReader sr = new StreamReader(fs);
string myInput = sr.ReadToEnd();
sr.Close();
fs.Close();

DateTime dtFile = Convert.ToDateTime(myInput);

DateTime dt2 = DateTime.Now;

TimeSpan span = dt2.Subtract(dtFile);
int dif = span.Days*60*24 + span.Hours*60+span.Minutes;
if (dif > 5)//>60
{
RunRoutines();
}

}

Entry Filed under: Script, c-sharp. Tags: , , , , , , , , , , , , , , , .


Archives

Other

Categories

 

July 2008
M T W T F S S
« Jun   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031  

Tags