timer

Memory leak with Timer

岁酱吖の 提交于 2019-12-24 00:23:03
问题 I am using a timer that is canceled and restarted on a listener event. It all works fine except that the the timer thread leaks the whole outer class. My timer implementation is as follows: if(timer != null) { timer.cancel(); timer = null; timer = new Timer(); } timer.schedule(new TimerTask() { // Thread leaks!!!! @Override public void run() { mCallback.onHeaderMoving(newToolbarTranslationY ); } } , 150); I used MAT Analyser to track down the problem and ended up there. I also commented out

stm32 how to make pulse count up/down with timer

主宰稳场 提交于 2019-12-24 00:22:52
问题 I need for my personal project counting pulse and direction with timer. With this code I can count only one direction. Any suggestion are welcome for correct code (this code is pretesting) pulse count to PA_9 and direction input to PA_8 #include "mbed.h" #include "stm32f4xx.h" #include "stm32f4xx_hal_tim_ex.h" TIM_HandleTypeDef timer; TIM_Base_InitTypeDef inizializza; TIM_IC_InitTypeDef startclock; TIM_ClockConfigTypeDef ClockConfig; TIM_SlaveConfigTypeDef sSlaveConfigure; TIM

SetTimer generate a random IDEvent

一曲冷凌霜 提交于 2019-12-24 00:13:47
问题 When I try to use the Windows SetTimer function, it generate a IDEvent for the timer even if I have specified one! This: SetTimer(0,999,10000,@timerproc); In: procedure timerproc(hwnd: HWND; uMsg: UINT; idEvent: UINT_PTR;dwTime: DWORD); stdcall; begin KillTimer(0, idEvent); showmessage(inttostr(idevent)); end; Return: Random Number! Is it possible to manage my timers by myself instead of Windows choosing for me? Thank you very much! 回答1: If you want to handle multiple timer events in a single

How to interchange between 2 timers? in Java GUI

 ̄綄美尐妖づ 提交于 2019-12-24 00:08:46
问题 Okay, so basically what I'm trying to create a timer that counts up and down. I need the program to activate just one timer at any one time. There are two timers, one causing a variable to increment, the other to decrement. I can't seem to get it right, when I press the increment, the variable increments but never stops, even when I press the decrement button. How do I go about doing this? Also, another quick question : How do I return a value which is within a keypress method? Keypress are

Stop timer in the middle of the tick

倖福魔咒の 提交于 2019-12-23 22:55:59
问题 I want to stop a timer but in the middle of the tick, before the tick finishes. But when I use a button to stop the timer, it only stops it after the tick finishes all his functions. I'm using 4 radiobuttons and a timer that keeps changing the selected radiobutton. When I press the Stop button, my timer stops and I need to know what radiobutton is selected, but the timer just stops after the tick finishes, so the selected radiobutton changes. The code is: namespace teste_bola { public partial

Behaviour of System.Timer when Interval property changed

萝らか妹 提交于 2019-12-23 22:22:38
问题 I have a System.Timer setup to trigger an event every day at 2AM. If the process the timer starts fails then I want the timer to be reset to run every 15 minutes until the process completes succesfully. // this is how the timer is set up. // this is working correctly. double startTime = milliseconds_of_hour_to_start. Timer = new System.Timers.Timer( startTime); Here is the code to reset the timer on success or failure of the event handler. NOTE the timer is not being stopped, just the

How to get current time from Angular Timer

狂风中的少年 提交于 2019-12-23 20:32:07
问题 I am testing the Angular Timer and have found myself wondering about how to get the current time inside my controller in order to use it to whatever purpose I might have. For instance, I want to set the font color of the timer to red when it reaches a specifict amount of minutes , but I was completely unable to do this. I tried the following: $scope.startTimer = function (deadline) { $scope.$broadcast('timer-start'); $scope.timerRunning = true; if ($scope.minutes == deadline) $scope.turnRed()

Threaded timed loops in Perl

我是研究僧i 提交于 2019-12-23 20:23:34
问题 I'd like to, essentially, have a high-priority thread, that runs at a given interval (here 0.5 ms) and interrupts "everything", executes a short task, and then goes back to 'sleep'; using Ubuntu 11.04 and perl v5.10.1. The problem is, while I'm getting some sort of results, I am not sure whether it's possible to get "tight timing". I have made three test scripts, in which the 'loop' is basically increasing a counter 10 times, taking timestamps - and then it terminates, and the timestamps are

C++ Timer pausing execution of program until finished

≡放荡痞女 提交于 2019-12-23 19:46:28
问题 C++, XCode 4.6.3, OSX 10.8.2, deploying on iOS I am trying to create a timed event. My thought process was to create a thread, do the timing in it and then at the end have it call another function. This is working however it is pausing the rest of the program. //Launch a thread std::thread t1(start_thread); //Join the thread with the main thread t1.join(); void start_thread() { std::cout << "thread started" << std::endl; auto start = std::chrono::high_resolution_clock::now(); std::this_thread

How to raise only 1 Timer event in C#?

穿精又带淫゛_ 提交于 2019-12-23 19:13:52
问题 How do I get a timer event to fire one at a time. For example I have a timer that raises an event every 10 minutes. The event that is raised takes 10 or more minutes to finish executing. I would like the timer to reset AFTER the event has finished. In other words I do not want to raise more than 1 instance of the event at any one time. 回答1: Usually what I do is have my event stop the timer when it's raised and then restart the timer when the event process completes: private void timerHandler