public Form1() { InitializeComponent(); TimerClock.Interval = 1000; TimerClock.Start(); // Create a timer that will call the ShowTime method every second. // 윈폼 타이틀바에 시계표시 //var timer = new System.Threading.Timer( ShowTime, null, 0, 1000 ); watcher.Path = @"C:\Temp"; watcher.Filter = "*.txt"; watcher.EnableRaisingEvents = true; // 텍스트 박스 //watcher.Renamed += new RenamedEventHandler( ( o, e ) => { UpdateTextBox( Environment.NewLine + e.Name + " : is Renamed" ); } ); //watcher.Changed += new FileSystemEventHandler( ( o, e ) => { UpdateTextBox( Environment.NewLine + e.Name + " : is Changed" ); } ); //watcher.Created += new FileSystemEventHandler( ( o, e ) => { UpdateTextBox( Environment.NewLine + e.Name + " : is Created" ); } ); //watcher.Deleted += new FileSystemEventHandler( ( o, e ) => { UpdateTextBox( Environment.NewLine + e.Name + " : is Deleted" ); } ); // 리스트 박스 //watcher.Changed += new FileSystemEventHandler( ( o, e ) => { UpdateListBox( e.Name + " : is Changed" ); } ); watcher.Created += new FileSystemEventHandler((o, e) => { UpdateListBox(e.Name + " : is Created"); }); watcher.Deleted += new FileSystemEventHandler((o, e) => { UpdateListBox(e.Name + " : is Deleted"); }); watcher.Renamed += new RenamedEventHandler((o, e) => { UpdateListBox(e.Name + " : is Renamed"); }); }
public void TimerClock_ClockTicksEqualThreadTimerTicks(int sleepSeconds) { var ticks = 0; var clock = new TimerClock(1000, args => ticks++); clock.Start(); Thread.Sleep(sleepSeconds * 1000); //=== Manual Step : Check CPU to see processor efficiency. clock.Stop(); Console.WriteLine(ticks); }
static void Main(string[] args) { TimerClock timer = new TimerClock(); AlarmClock alarm = new AlarmClock(); alarm.Subscribe(timer); Phone phone = new Phone(); phone.Subscribe(timer); timer.Start(10); Console.ReadKey(); }