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: .net 1.1, .net 2.0, .net 3.0, ADO.NET, c#, c-sharp, controls, DataSet, datasource, Framework, internet-life, query, sql-datetime, Visual Studio 2008, visual-studio-2005, winforms.
Trackback this post | Subscribe to the comments via RSS Feed