I am making an application that checks if there are files in a certain folder, if there is, it un-minimizes the application.
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(tick);
aTimer.Interval = updateIterval*1000;
aTimer.Enabled = true;
public void tick(object source, ElapsedEventArgs e)
{
update();
}
public void update()
{
MessageBox.Show("Tick");
if (WorkingFiles.Length != 0)
{
this.WindowState = FormWindowState.Normal;
MessageBox.Show("Normal");
}
else
{
this.WindowState = FormWindowState.Minimized;
MessageBox.Show("Minimized");
}
}
I will only get the "TICK" message every 10 seconds, and I wont get either of the "Normal", or "Minimized" but if I call this function via button press it works perfectly fine. not sure if there is something inherently wrong with the way I am doing this, or if I could do it another way?
FileSystemWatcherclass ?