timer

Using a timer to delay a line by line readline method C#

不羁的心 提交于 2021-01-29 17:43:04
问题 I am using C# Windows Forms using Visual Studio 2010. Don't let the Console part confuse you it's a user defined thing not the actual console. So I have a method that prints a file line by line. I have to make it appear to print slowly so I am currently using Thread.Sleep to slow the line by line printing. I cannot use this because it freezes up some other components in the program. I was hoping to see if this could be done with a timer instead. Though all the examples I see being used with a

How to add a timer to a dynamic created labels in a winform C#?

余生颓废 提交于 2021-01-29 14:41:44
问题 I have a small app that creates dynamically a panel that includes a table layout panel where there is a list box and a label. The question is how I'm gonna assign a timer in every label created dynamically and also how I'm gonna start the timer from 00:00? I have tried this code but only adds the timer to the last label in the last panel created: public Form1() { InitializeComponent(); p = new Panel(); p.Size = new System.Drawing.Size(360, 500); p.BorderStyle = BorderStyle.FixedSingle; p.Name

Millisecond timer?

半城伤御伤魂 提交于 2021-01-29 13:46:22
问题 Does anyone know how to make a timer with a time interval of 0.001? I read somewhere that a Timer can't have a time interval lower than 0.02, and my timer is behaving that way. My timer: timer = Timer.scheduledTimer(timeInterval: 0.001, target: self, selector: #selector(self.updateTimer), userInfo: nil, repeats: true) @objc func updateTimer() { miliseconds += 0.001 } 回答1: Yes, you can have time intervals less than 0.02 seconds. E.g. 0.01 second interval is easily accomplished. But at 0.001 or

JAVA SWING - Creating Animation using Swing Timer

你离开我真会死。 提交于 2021-01-29 10:01:52
问题 I am trying to setup a program that enables the user to display a transition when clicking the next and previous button. When pressing next, the swing timer should trigger and start the animation. When transitioning, there should be a flag that states it is in the transition period. The Swing timer should fire once every tenth of a second and essentially last 1 second. public class guiCreation { static Timer timer; static boolean flag = false; private static void guiInterface() { next

How to create a timer/counter in C# XNA

给你一囗甜甜゛ 提交于 2021-01-29 08:11:45
问题 I'm fairly new to C# programming, and this is my first time using it in XNA. I'm trying to create a game with a friend, but we're struggling on making a basic counter/clock. What we require is a timer that starts at 1, and every 2 seconds, +1, with a maximum capacity of 50. Any help with the coding would be great! Thanks. 回答1: To create a timer in XNA you could use something like this: int counter = 1; int limit = 50; float countDuration = 2f; //every 2s. float currentTime = 0f; currentTime +

JQuery wait for x sec. of inactivity before calling function

六月ゝ 毕业季﹏ 提交于 2021-01-29 04:49:05
问题 I have a form with multiple buttons, sliders, etc. that all trigger a main ajax pricing function when clicked, dragged, etc. Often a button is clicked multiple times consecutively in a short amount of time (e.g. a + button to increase a value). Instead of calling the main ajax function each time, I would like JQuery to wait for 1 sec after the LAST trigger event is done before executing. In other words, if the function is triggered < 1s since the last trigger... wait. 回答1: I would do a

Swing Timer not working as planned

ⅰ亾dé卋堺 提交于 2021-01-29 04:28:17
问题 I Think this is a Timer issue, first time ive used them and i feel like im doing it wrong. I have a method that for testings sake, input 6 images and with the help of a timer paints them to a JPanel: private void drawDice(Graphics2D g2d) throws IOException, InterruptedException { image = ImageIO.read(getClass().getResourceAsStream("/1.png")); m_dice.add(image); image = ImageIO.read(getClass().getResourceAsStream("/2.png")); m_dice.add(image); image = ImageIO.read(getClass()

Creating a stopwatch from scratch in JavaScript

£可爱£侵袭症+ 提交于 2021-01-29 03:14:45
问题 By creating variables for milliseconds, seconds, and minutes, I wanted to make a little stopwatch project. The onClick for the button I have is for theTimer() : var milli = 0; var seconds = 0; var minutes = 0; var onOff = 0; var txtMilli = document.getElementById("txtMilli"); var txtSeconds = document.getElementById("txtSeconds"); var txtMinutes = document.getElementById("txtMinutes"); function theTimer() { if (onOff == 0) { onOff = 1; timer = setInterval("startCounting()",1); } if (onOff ==

Javascript timer to switch functions

无人久伴 提交于 2021-01-29 02:24:43
问题 I have three functions called toggle1() , toggle2() , toggle3() linked to my html. I want to make a timer to call each function with a delay of 5 seconds (5seconds for testing). I wrote this code, but it doesn't work. Any tips on how to make it work? I have used function init() when the page loads function timer() { var i = 1; var delay = 5000; for (i, i = 3, i++) { switch (i) { case 1: toggle1(); delay; break; case 2: toggle2(); delay; break; case 3: toggle3(); delay; break; } } } 回答1: First

Javascript timer to switch functions

纵饮孤独 提交于 2021-01-29 02:23:23
问题 I have three functions called toggle1() , toggle2() , toggle3() linked to my html. I want to make a timer to call each function with a delay of 5 seconds (5seconds for testing). I wrote this code, but it doesn't work. Any tips on how to make it work? I have used function init() when the page loads function timer() { var i = 1; var delay = 5000; for (i, i = 3, i++) { switch (i) { case 1: toggle1(); delay; break; case 2: toggle2(); delay; break; case 3: toggle3(); delay; break; } } } 回答1: First