Timer not working
So i want a simple timer for my WPF app so i can run a Update each second but it sends an update every 2-3s instead how do i fix it?
11 Replies
what makes you say that?
why in the world do you have a lock() there?
in WPF u shouldnt use the
Timer
but the DispatcherTimer
, especially because it seems like u r updating gui elements on their ticks (see the Remarks section of the link)
https://learn.microsoft.com/en-us/dotnet/api/system.windows.threading.dispatchertimer?view=windowsdesktop-7.0DispatcherTimer Class (System.Windows.Threading)
A timer that is integrated into the Dispatcher queue which is processed at a specified interval of time and at a specified priority.
so i made some changes
and it still goes every 2-3s not 1s
wel,, u increment by one, so every 2 out of 3 ticks nothing happens in ur
Update()
method
1. tick = elapsedTime = 1 -> nothing happens
2. tick = elapsedTime = 2 -> nothing happens
3. tick = elapsedTime = 3 -> IncreaseCurrentMoney(power1Output)
will be called
4. tick = elapsedTime = 4 -> nothing happens
5. tick = elapsedTime = 5 -> nothing happens
6. tick = elapsedTime = 6 -> IncreaseCurrentMoney(power1Output)
will be called
and so onUnknown User•2y ago
Message Not Public
Sign In & Join Server To View
thats +1 not +10, its
power<number>Output
;pUnknown User•2y ago
Message Not Public
Sign In & Join Server To View
thats power one output for % 3 == 0, not power ten, for % 9 its two not twenty.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
well, yeah most likely they want an array for that ;p
yeah... idk why it took me so long to get it
everything was good
ye i remade it with if elses