timer

How can I make my own timer without standard library?

大城市里の小女人 提交于 2019-12-22 09:03:13
问题 Is there some specific number of iterations, that I could make using a for loop , so that it exactly takes 1 second for the loop to be executed completely? For example the following code took 0.125s on my machine to execute: #include <iostream> #include <cmath> using namespace std; int main(){ long long a=0; for (a=0;a<=pow(10,4);a++); } Though, a <= 8*pow(10,4) took 0.206 s. Compiler is GCC 4.9.2. IDE is codeblocks. My PC's Specs: OS: Windows 8.1 回答1: I am posting this answer to your

How to create timer on JINT Javascript side

别来无恙 提交于 2019-12-22 08:59:22
问题 I´m developing a C# project using JINT (https://github.com/sebastienros/jint), and I need to create a timer on my JS so it can execute a function on my javascript every time the timer tim set is elapsed. How can I accomplish that?. I have used setInterval or setTimeout functions but it seems that they are not part of JINT since it is based on ECMASCRIPT and this functions are not native. Can someone tell me how I can do this?. Thanks!! 回答1: Neither setInterval and setTimeout are supported by

Set Timer on Swift

怎甘沉沦 提交于 2019-12-22 08:57:13
问题 Im trying to execute the function pepe() repeated times, i get no errors but it doesnt work. Here is my code: public class MyClass { var timer = Timer() @objc func pepe() -> String { let hola = "hola" return hola } func startTimer(){ let seconds = 1.0 timer = Timer.scheduledTimer(timeInterval: seconds, target: ().self, selector: #selector(pepe), userInfo: nil, repeats: false) } func stopTimer() { timer.invalidate() } init() { self.startTimer() self.stopTimer() } } var pepe = MyClass() pepe

Timed Alarm in Excel VBA

萝らか妹 提交于 2019-12-22 08:37:03
问题 I made a calendar to track tasks and similar items in Excel 2003. What I need to be able to do is to set a timer via VBA. Something like this: run_in_x_secs ( timetowait, function to exec) Is there a way to do that in excel vba, or should I try and find an alarm to run via the command line and run that from VBA. How would you do it? 回答1: This should do the trick: Public Sub RunSubInXSeconds(secondsToWait As Long, nameOfFunction As String) Application.OnTime Now + secondsToWait/(24# * 60# * 60

Not receiving location data from thread

孤者浪人 提交于 2019-12-22 08:24:43
问题 I'm trying to send text messages containing the users location every so often using the timer. Initially, I ran into a nullpointerexception which was due to a simple mistake I made. Once this was fixed everything seemed to be running fine. However, it never gets my location, so, the text that keeps sending is saying "Could Not receive location". What I am asking is why is it not getting my location? And what can I do to fix the problem? There are no logcat errors and I am using two emulators

How to create a countdown timer with jQuery?

≡放荡痞女 提交于 2019-12-22 08:24:28
问题 I'll have more than one of these small boxes on my site, and each will start counting down at different times. How can I decrease the numerical value of the timer per second, giving the simulation of a countdown timer? <p class="countdown">15</p> Using this javascript it correctly countsdown, but every single auctionbox is affected. How would you suggest I isolate the timer to act on only one item? <script> var sec = 15 var timer = setInterval(function() { $('.auctiondiv .countdown').text(sec

The best way to refresh my .aspx site with a Timer in C#?

天涯浪子 提交于 2019-12-22 08:14:35
问题 I have a default.aspx page that needs to be refresh every 10 sec. My solution so far is a javascript function, but it only works in Firefox and not IE. I'm looking for a way to handle the refresh mecanism in the default.aspx.cs page instead, with some sort of Timer. Any good simple sugestions/hints or solutions out there that can lead me in the right direction? 回答1: There is a timer that is included with ms ajax in the toolbox. Add a ScriptManager, put the content you want refreshed inside an

wpf storyboard death

微笑、不失礼 提交于 2019-12-22 08:12:25
问题 C#: public partial class MainWindow : Window { Storyboard a = new Storyboard(); int i; public MainWindow() { InitializeComponent(); a.Completed += new EventHandler(a_Completed); a.Duration = TimeSpan.FromMilliseconds(10); a.Begin(); } void a_Completed(object sender, EventArgs e) { textblock.Text = (++i).ToString(); a.Begin(); } } XAML: <Window x:Class="Gui.MainWindow" x:Name="control" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx

In JavaScript, is there a source for time with a consistent resolution in milliseconds?

余生长醉 提交于 2019-12-22 08:10:02
问题 The Date object in JavaScript performs differently machine to machine and browser to browser in respect to the function's resolution in milliseconds. I've found most machines have a resolution of about 16 ms on IE, where Chrome or Firefox may have a resolution as good as 1ms. Is there another function available to JavaScript in general or IE specifically that will give a better time resolution? I am trying to trap and record keyDown and keyUp times in milliseconds and need it in the +/- 10 ms

Code should be executed one time after short delay

天大地大妈咪最大 提交于 2019-12-22 07:41:05
问题 I have this Timer : Timer delayTimer = new Timer(); delayTimer.Interval = 500; delayTimer.Elapsed += (object sender, ElapsedEventArgs e) => { Console.WriteLine("test"); textInputDialog.Show(); delayTimer.Stop(); }; delayTimer.Start(); Here I have the following problems: Timer never stops. Code is executed every 500ms. textInputDialog.Show(); doesn't work (perhaps cause of problem above) What is wrong with my code? Alternative solutions: This is an alternative to timer as Jens Horstmann