timer

Golang Timers with 0 length

爱⌒轻易说出口 提交于 2019-12-24 03:52:58
问题 I've written a code snipped that creates a timer with a 0 length time, and it does not immediately expire (which is what I expected). A very short sleep call does make it expire, but I'm confused as to why. The reason I care is that the code using this idea has a snippet that returns 0 on a low probability error, with the idea that the timer should be set to immediately expire, and retry a function. I do not believe that the nanosecond sleep needed here will affect my implementation, but it

display a timer using progressBar xamarin forms

孤街浪徒 提交于 2019-12-24 03:27:54
问题 how to add a nice timer xaml : <ProgressBar x:Name="progressBar" Grid.Row="2" Grid.ColumnSpan="5" IsVisible="true" Progress="0.0" WidthRequest="300" HeightRequest="20" VerticalOptions="Center" HorizontalOptions="Center"> </ProgressBar> behind code : progressBar.Progress = 0; await progressBar.ProgressTo(1.0, 90000, Easing.Linear); 回答1: You can use a timer to increment the ProgressBar : var updateRate = 1000 / 30f; // 30Hz double step = updateRate / (2 * 30 * 1000f); Device.StartTimer(TimeSpan

How to workaround a nodejs stable bug with setInterval/setTimeout when changing system time

泪湿孤枕 提交于 2019-12-24 03:18:25
问题 In the current stable version of node.js v0.10.33 there is a bug where setTimeout/setInterval does not fire anymore when setting the system time to the past. Run this code to see what I mean: var i = 0; var handle = setInterval(function() { console.log(++i); }, 1000); Then while it's running change the time of your system to the past, does not matter if on windows or linux. The interval / timeout will not fire anymore. When chaning the time to the future, node behaves perfectly fine and keeps

Android CountDownTimer Class Lagging Main Thread

﹥>﹥吖頭↗ 提交于 2019-12-24 02:09:23
问题 I am trying to use android.os.CountDownTimer to literally show a countdown timer via a textview for fitness purposes. The issue I am having is the timer seems to be having trouble running on the main thread i.e. the countdown will jump 2-4 secs and is clearly being "lagged" - the timer is intended to be in an endless loop until a stop button is pressed. I am new to Java and Android and cannot figure out how to get the countdown timer running and updating the UI without any conflicts or

Android CountDownTimer Class Lagging Main Thread

这一生的挚爱 提交于 2019-12-24 02:09:11
问题 I am trying to use android.os.CountDownTimer to literally show a countdown timer via a textview for fitness purposes. The issue I am having is the timer seems to be having trouble running on the main thread i.e. the countdown will jump 2-4 secs and is clearly being "lagged" - the timer is intended to be in an endless loop until a stop button is pressed. I am new to Java and Android and cannot figure out how to get the countdown timer running and updating the UI without any conflicts or

Timer once a minute on the minute

浪子不回头ぞ 提交于 2019-12-24 01:46:32
问题 I can't get the timer to fire once a minute on the minue, 1:00, 1:01, 1:02 etc. Instead, when the timer executes drifts by a couple of seconds each iteration internal void StartTimer() { DateTime nowEastern = CalendarEntity.Calendar.GetEasternTime(); int secondsInterval = 5; double additionalSeconds = secondsInterval - nowEastern.TimeOfDay.TotalSeconds % secondsInterval; if (additionalSeconds == 0) { additionalSeconds = 1; } var nearestOnOneMinutes = new DateTime( nowEastern.Year, nowEastern

Win32 API timers

岁酱吖の 提交于 2019-12-24 01:44:11
问题 I was using the system timer (clock() function, see time.h) to time some serial and USB comms. All I needed was approx 1ms accurace. The first thing I noticed is that individual times can be out (plus or minus) 10ms. Timing a number of smaller events led to less accurate timing as events went by. Aggregate timing was slightly better. After a bit of a root on MSDN etc I stumbled across the timer in windows multi-media library (timeGetTime(), see MMSystem.h). This was much better with decent

android timer swing

回眸只為那壹抹淺笑 提交于 2019-12-24 01:24:56
问题 I need to create a Timer to update the UI at regular intervals. But the Swing Timer class is not available on Android. How can I work around this problem ? (I would avoid creating threads and then use the Timer class from java.util package) 回答1: You could use a Handler and the postAtTime() method or the postDelayed() method. This will allow you to schedule a Runnable to be executed at some point in the future. 回答2: Well, for your problem Handler class would suffice(+1 to Dave :)). FYI, there

Timer and pthreads (POSIX)

余生长醉 提交于 2019-12-24 01:07:17
问题 I'm using a pthread to schedule some tasks on my application. I copied the code from my old C version of the same application and it worked perfectly. Now I'm coding with C++ and it doesn't work anymore (basically it doesn't trigger the sigevent executing the given function). All creation and starting functions exit with rc 0, even when i use the timer_gettime. I simplified a lot the code to narrow down the issue but I could't find it yet: #include <signal.h> #include <time.h> int main (void)

VB6 killing timers

夙愿已清 提交于 2019-12-24 01:01:33
问题 I'm programming in VB6 because we are using legacy code and hardware (external electronics). My programs are build around timers where I would use tasks in OS programming. The timers are running until their job is done. A flag is set and another timer is started. I want a supervisory timer that controllers the other timers When the timers produce no result or are waiting for a real world event that never comes (Do while loop) I want to kill the timer. In electronics we have a 'watch dog timer