Skip to main content

New answers tagged

0 votes

Flutter Countdown Timer

A very simple example of using a generic CountdownTimer that is not related to the user interface. Just a few lines of code. import 'dart:async'; import 'dart:io'; import 'package:multitasking/misc/...
mezoni's user avatar
  • 11.3k
Best practices
0 votes
0 replies
0 views

How reliably and safely detect hardware timer overflow causing logic error

I will give you an example calculation. I will use hex values as it is easier to see where the overflow/underflow happens and we don't have to care about exact numbers. Simple example: Now: ...
Thibe's user avatar
  • 762
Best practices
1 vote
0 replies
0 views

How reliably and safely detect hardware timer overflow causing logic error

Signed overflow is undefined behaviour, unsigned arithmetic is defined (C++ standard) as performed modulo 2^bits_of_your_type, so it technically speaking doesn't overflow. However, this doesn't seem ...
Xellos's user avatar
  • 1,111
0 votes

How to create timer on JINT Javascript side

You can wrap Task.Delay() with a Jint promise, e.g. using Jint; internal class Program { private static async Task Main(string[] args) { TaskCompletionSource<object?> tcs = new ...
Stephen Quan's user avatar
  • 28.3k
Best practices
1 vote
0 replies
0 views

How reliably and safely detect hardware timer overflow causing logic error

It's simple to extend the timer using another 32-bit register: if (!++ticks) ++overflow; In ARM assembly, that's just one extra instruction. The overhead in testing is slightly more, but still in ...
Toby Speight's user avatar
  • 32.9k
Best practices
0 votes
0 replies
0 views

How reliably and safely detect hardware timer overflow causing logic error

Could you please elaborate? Do you mean that unsigned long is simply the wrong data type for the problem or that you don't see the logic bug described in the question? Or something else?
zero-day's user avatar
  • 402
Best practices
0 votes
0 replies
0 views

How reliably and safely detect hardware timer overflow causing logic error

Thanks Andrey, your suggestions are much appreciated. Yes, 490 thousand years will certainly suffice. The application controls truncation of an AC waveform so is very sensitive to timing. I'll just ...
zero-day's user avatar
  • 402
Best practices
1 vote
0 replies
0 views

How reliably and safely detect hardware timer overflow causing logic error

you are using unsigned long so overflow is well defined and I do not see a pro0blom.
Marek R's user avatar
  • 40.7k
Best practices
1 vote
0 replies
0 views

How reliably and safely detect hardware timer overflow causing logic error

and 2) are the same thing. 32-bit time counter + overflow counter is exactly the same as single 64-bit counter; except in single 64-bit case the compiler would do the job for you. It also does ...
Andrey Turkin's user avatar
0 votes

SwiftUI - How to Make A Start/Stop Timer

If you would like more modern solution (iOS 17+), without the publishing hassle and outdated Combine framework, yet maintaining start/stop functionality, you can use something like this: import ...
Vëx's user avatar
  • 1,408
0 votes

DispatcherTimer and Timer

why the System.Threading.Timer is loosing so much time approx. 3sec. in 5 min. the reason is race condition - to solve this problem you should marshal the call back to the UI thread either using a ...
JeeyCi's user avatar
  • 652

Top 50 recent answers are included