darthwillard
darthwillard

Reputation: 819

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 EventHandler(mp3Timer_Tick);

Upvotes: 1

Views: 2512

Answers (1)

Heinzi
Heinzi

Reputation: 172468

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.

Upvotes: 1

Related Questions