two dispatchertimer events at the same time?
i have a wpf app that is updating date/time in one dispatchertimer, another is for a mp3 player timer that tracks time and slidebar for playing time. is it possible to have 2 dispatchertimer's running?
that's dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
and dispatcherTimer.Tick += new EventHand开发者_开发知识库ler(mp3Timer_Tick);
Yes, it's possible.
What you are doing is something different: You are trying to attach two event handlers to one DispatcherTimer. Don't do that. If you want two timers for different purposes (and with different timeouts), use two DispatcherTimer objects:
dateTimeTimer.Tick += new EventHandler(dateTimeTimer_Tick);
mp3Timer.Tick += new EventHandler(mp3Timer_Tick);
Then you can do something like...
mp3Timer.Stop();
...when the music stops playing, and it won't affect the dateTimeTimer
.
精彩评论