db34

db34

  • NA
  • 3
  • 0

a timer stops functioning after a FileSystemWacher event occurs

Sep 26 2003 8:49 AM
hi I have the following small program ============================ using System.IO; Timer tm1 = new Timer(); FileSystemWatcher wch = new FileSystemWatcher(); private void Form1_Load(object sender, System.EventArgs e) { tm1.Interval=10000; tm1.Enabled=true; tm1.Tick+= new EventHandler(TimerTick); wch.Changed += new FileSystemEventHandler(OnChanged); wch.Created += new FileSystemEventHandler(OnChanged); wch.Deleted += new FileSystemEventHandler(OnChanged); wch.Path=("c:\\temp"); wch.EnableRaisingEvents = true; } private void TimerTick(object sender, System.EventArgs e) { tm1.Enabled=false; MessageBox.Show("timer1"); tm1.Enabled=true; } private void OnChanged(object o, FileSystemEventArgs e) { tm1.Enabled=false; MessageBox.Show("file " + e.FullPath + " has been changed"); tm1.Enabled=true; } ===================== The timer tm1 functions properly untill the OnChanged event occurs then the Enable =true fails there is no error message the timer just stops responding . When i put the same enable/disable commands on another event(TimerTick) they work! what did i miss ??? thank's tami

Answers (2)