Hot answers tagged

7

To start, it's crucial that you stop creating a brand new label ten times a second. Just modify the existing one. Also, this is so simple that a class is not called for. Move as much as possible away from your thread, into your setup routine. Finally, your use of %H is likely incorrect given that you also include %p; you probably want %I for a 12-hour clock. ...


4

First of all, your function doesn't return anything and so you can remove -> bool since it only creates confusion. You can either use -> None or use nothing at all. Still related to type annotations, I find it kinda hard to read your code with annotations everywhere. This is subjective and it's just my personal preference but I usually tend to use type ...


3

HTML The inline onClick event handler attached to your HTML element probably works fine; however there are better ways to deal with the events in pure JS. Next time, add the event handlers in the JS file like so: element.addEventListener('click', callbackName). h1 is a header. I'd not place the timer value inside that particular tag. I think that span would ...


3

From a short review; You use 9 twice, this should be assigned to a nicely named global constant You hard code both 9 and 00:10, this is not flexible. I would expect to be able to change 9 to 99 and to have the timer start at 01:40 Similarly, 00:0${startingTime--} does not allow for much flexibility in the script The browser tries to honor the 1000, but it ...


2

Avoid storing data unnecessarily Your class stores the start time, stop time and frequency in member variables, however you only need to store the start time: class Timer { LARGE_INTEGER start_count; public: // Query performance counter at the start of a block of code void start() { QueryPerformanceCounter(&start_count); } //...


2

Welcome to codereview.se and thanks for sharing your code. Here is what I think about it. Please keep in mind, that this is my personal view on it. Do not use the Java Singelton pattern. The singelton pattern is just another name for a global variable, which we consider harmful and bad coding since the early days of programming. Also the pattern is not that ...


2

Countdowns Some points missed or skimmed over by other answers. Visibility: Always keep DOM interaction to a minimum. In timers you should check if the document is visible before you make changes that may not be viewed by the client. Timers are one such app that contains animations that the client will not continually watch. Use the page visibility API to ...


1

Try this collection to hold your messages. It should do exactly what you are looking for - just create couple instances for errors and warnings. public class MessageCollection : ObservableCollection<string> { public MessageCollection() { Timer = new Timer(Callback, this, 5000, 5000); CollectionChanged += ...


1

I took a moment to rewrite your proposal to give you an alternative to compare with. In this version the Timer consumes a length indefinite list of task (a channel), context are used extensively to solve timeout management and exit sequences. The switching to short/long break is a simple modulo statement of a counter. package main import ( "context&...


Only top voted, non community-wiki answers of a minimum length are eligible