timer

Android location update every minute

大兔子大兔子 提交于 2019-12-25 07:34:00
问题 I am currently writing an application that receives location data every minute (or other specified amount of time) and thes send it to server. The problem that I have noticed is: When I use my application connected to power source it works perfectly - sends updates with defined interval. When I use it on battery it sends updates randomly. For my application I use timer to specify interval of update. This timer runs in Background service. I request updates in timer and remove updates when I

How do I emulate a timer inside an object that will periodically mutate the object?

可紊 提交于 2019-12-25 07:28:48
问题 In my project I need to do something like: use std::thread; use std::time::Duration; struct A { pub ints: Vec<u8>, } impl A { fn new() -> A { let mut a = A { ints: vec![1, 5, 6, 2, 3, 4], }; a.timer(); a } fn timer(&mut self) { thread::spawn(move || { loop { thread::sleep(Duration::from_millis(1)); self.ints.remove(0); } }); } } fn main() { let a = A::new(); loop { println!("Remaining elements: {:?}", a.ints); } } The idea is that some struct contains a vector of elements. These elements

How do I emulate a timer inside an object that will periodically mutate the object?

半城伤御伤魂 提交于 2019-12-25 07:28:10
问题 In my project I need to do something like: use std::thread; use std::time::Duration; struct A { pub ints: Vec<u8>, } impl A { fn new() -> A { let mut a = A { ints: vec![1, 5, 6, 2, 3, 4], }; a.timer(); a } fn timer(&mut self) { thread::spawn(move || { loop { thread::sleep(Duration::from_millis(1)); self.ints.remove(0); } }); } } fn main() { let a = A::new(); loop { println!("Remaining elements: {:?}", a.ints); } } The idea is that some struct contains a vector of elements. These elements

Prevent session time out if javascript timer is running

。_饼干妹妹 提交于 2019-12-25 06:58:23
问题 I have a web application made in Code igniter. What it basically does is - user logs in to the application User can do various tasks, one of which is timer based tasks. There is a button which starts the javascript timer While timer is running he performs certain tasks, and once he is done, he stops the timer. The timer may run for few minutes to few hours. My Question - While JavaScript timer is running, can we prevent session timeout, so that users are not logged out and their progress is

Setting a Timer for a timeout - new Timer() fails after cancel and purge

烈酒焚心 提交于 2019-12-25 06:45:55
问题 I have some location finding code and while I'm waiting for a read of an appropriate accuracy I'd also like to have a timeout and use whatever the best location read is up to that point. I seem to be misunderstanding how to cancel and restart a timer. I want to start a timeout timer when I begin my search and restart the timer every time I repeat my search... private void refreshLocation() { if (locationTimeoutTimer != null) { locationTimeoutTimer.cancel(); locationTimeoutTimer.purge(); }

C# Timer elapsed one instance at a time

懵懂的女人 提交于 2019-12-25 06:33:42
问题 I am creating windows service. I want to run the service every 30 seconds. So I have used timer on windows service start using the following code. protected override void OnStart(string[] args) { timer1 = new Timer(); timer1.Interval = 30000; timer1.Elapsed += new ElapsedEventHandler(timer1_tick); timer1.Start(); } In timer1_tick function, I am performing some actions like updating user details, uploading and downloading files. But here I am not sure that the above action will finish within

QueryPerformanceCounter() vs QueryInterruptTime() vs KeQueryInterruptTime()

情到浓时终转凉″ 提交于 2019-12-25 06:23:59
问题 I am writing a fast and fairly accurate game timer for use on Windows. Microsoft recommends using QueryPerformanceCounter() for high-resolution timing, and it works as expected, but I am looking for alternatives that yield less execution overhead. I did some Googling and found mention of QueryInterruptTime(), and its counterpart QueryInterruptTimePrecise() which should be more precise but incurs greater overhead. Their documentation (here and here) describes that they get the system interrupt

Calling a method every Day, every Week , every month and every year

▼魔方 西西 提交于 2019-12-25 06:14:17
问题 I need to autoSend reports to my clients at perticular timings like every day at 00:01 AM every Week at Sunday 00:01 AM on day 1 of every month on day 1 of every year For every day i am doing this : public void contextInitialized(ServletContextEvent arg0) { System.out.println("context initiallized"); System.out.println("Starting timer"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 1); calendar.set(Calendar.SECOND, 0); Date

Take time in microseconds between two functions

扶醉桌前 提交于 2019-12-25 05:35:26
问题 Hi I have tried different solutions but I can't find what I'm looking for, what I want to do is to take the time in microseconds between two functions. But the problem is first that I need to start the timer right after a css animation has finished, second I need to stop the timer when someone presses either B or R on the keyboard, and third I need to send the time from the timer with the information about which key that was pressed. Here's a code to show what I mean, first one is to call the

How to change Linux interrupt timer for tcsetattr()

淺唱寂寞╮ 提交于 2019-12-25 05:31:34
问题 I am using serial port , and while communicating with this, i have to change the configuration using tcsetattr() with TCSDRAIN mode. TCSADRAIN The change should take place after all output written to fd has been read by the master pseudoterminal. Use this value when changing terminal attributes that affect output. And while calling tcsetattr() with TCSDRAIN , if there still remain output data in buffer, Linux seems blocked and check the buffer again after a some interrupt time to change a