Dispatchertimer
Program/C# 2008. 2. 29. 13:22C# 에는 타이머가 3개(?정확히 기억이..) 정도 존재하는 걸로 기억하는데
그중 하나인 DispatcherTimer 입니다.
그중 하나인 DispatcherTimer 입니다.
C#
// DispatcherTimer setup dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0,0,1); dispatcherTimer.Start();
The Tick event handler updates a Label that displays the current second, and it calls InvalidateRequerySuggested on the CommandManager.
C#
// System.Windows.Threading.DispatcherTimer.Tick handler // // Updates the current seconds display and calls // InvalidateRequerySuggested on the CommandManager to force // the Command to raise the CanExecuteChanged event. private void dispatcherTimer_Tick(object sender, EventArgs e) { // Updating the Label which displays the current second lblSeconds.Content = DateTime.Now.Second; // Forcing the CommandManager to raise the RequerySuggested event CommandManager.InvalidateRequerySuggested(); }
'Program > C#' 카테고리의 다른 글
ElementHost 윈어플과 WPF 어플간의 컨트롤 사용 (2) | 2008.02.29 |
---|---|
FileSystemWatcher 폴더내 파일 변화 감시 (0) | 2008.02.29 |
Dll 로드시 자료형.. (1) | 2008.02.13 |