timer

What is the correct way to restart a ScheduledExecutorService scheduled task?

I have a scheduled task (running in fixed delay execution), started like this: executoreService.scheduleWithFixedDelay(repeatingThread, 0, numOfSeconds, TimeUnit.SECONDS); On every start of cycle, I check for a change in a settings file, and then I want to restart the task. The settings file also contains length of the interval (numOf...

How to build a very-low resolution timer ?

I need to implement a windows service that performs database import, and that once a month. The program receives data via e-mail, and will import them at the end of each month. Is there a better way than set the program to sleep for max_integer seconds/miliseconds repeatedly ? ...

linux/timer.h setup_timer() expiration function not working?

So the TimerExpire function in my setup_timer() causes a huge panic (will post below), while the regular function call to TimerExpire() will actually print out my input. void TimerExpire(char* data) { printk("Timer Data: %s\n", data); } setup_timer(&my_timer, TimerExpire, (char *)args); printk("Made timer: %s\n", (char *)args); Tim...

Creating an Ajax timer in Ruby/Rails?

I'm trying to figure out the best solution to create a "game-round" timer in Ruby/Rails. Right now I'm just jotting notes, but in theory I'd like to set a 30 second timer on each round of game activity. Once the timer hits 0, the users turn is over. On Ruby's end, I know I can accomplish this with a while loop and sleep(30), or some c...

Win32 API timers....

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. Aft...

How to timeout a thread

I want to run a thread for some fixed amount of time. If it is not completed within that time, I want to either kill it, throw some exception, or handle it in some way. How can it be done? One way of doing it as I figured out from this thread is to use a TimerTask inside the run() method of the Thread. Are there any better solutions fo...

schedule a console application using c#

Let me preface this by saying that I'm pretty green to C# and .NET development in general. That being said, I'd like to schedule a console application to run some code once every 24 hours. I'm open to any form of implementation, including timers, schedulers, or even a separate application that would call my console application, as long...

How do I display a message only if a certain amount of time has elapsed jquery - prevent form submission

I've got a checkout page which has some ajax calls that update hidden fields when the user changes delivery country for instance. Most of the time, this works fine, the page has time to update hidden fields before the user clicks submit. Some of the time though, due to slow connection or whatever the ajax doesn't return the hidden field...

Delete huge number of rows from an EJB Timer

I need to delete millions of rows from a table from within an EJB Timer. The problem is that the timer has a transaction timeout of 90 seconds, so I should divide the work into bite-size chunks. Since I don't know how many rows can be deleted in 90 seconds the algorithm should loop and delete a few at a time until the time is almost up....

How to time an operation in milliseconds in Ruby?

Hello, I'm wishing to figure out how many milliseconds a particular function uses. So I looked high and low, but could not find a way to get the time in Ruby with millisecond precision. How do you do this? In most programming languages its just something like start=now.milliseconds myfunction() end=now.milliseconds time=end-start ...

python timer mystery

Well, at least a mystery to me. Consider the following: import time import signal def catcher(signum, _): print "beat!" signal.signal(signal.SIGALRM, catcher) signal.setitimer(signal.ITIMER_REAL, 2, 2) while True: time.sleep(5) Works as expected i.e. delivers a "beat!" message every 2 seconds. Next, no output is produced: ...

jQuery Stopping and Starting Timers

Hi I have a demo going here of my site: treethink.treethink.net/backup I have the retracting news ticker on the right on a timer, when you click a nav item I got the ticker to retract but I need to end the timer so that it stays retracted. Then when you click the close button I need to start the timer again. Here is my jQuery: /* ...

Passing Arguments wrongly? C Question

When my TimerExpire function is finally called when the timer ticks out, it prints out gibberish. Anyone know why? But my printk function in IOCTL_MAKE_TIMER prints out correctly, so I think it's because I'm passing in the data wrong. setup_timer() works by setting up the timer in the first argument, telling it to call the function spec...

Timestamp, timers, time question

Hi all, I've been Googling Java timestamps, timers, and anything to do with time and Java. I just can't seem to get anything to work for me. I need a timestamp to control a while loop like the pseudo-code below while(true) { while(mytimer.millsecounds < amountOftimeIwantLoopToRunFor) { dostuff(); } mytimer.r...

Using timers in Flex

Hello, I am programming an aplication with Adobe Flex, but because i just begining with this language a couple of days ago i have a lot of doubts. I have created two states and a transition between them, now my goal is to programatically switch over and over again between these two states every 5 seconds. I aproach this using timer obj...

Timer, event and garbage collection : am I missing something ?

Consider the following code : class TestTimerGC : Form { public TestTimerGC() { Button btnGC = new Button(); btnGC.Text = "GC"; btnGC.Click += (sender, e) => GC.Collect(); this.Controls.Add(btnGC); System.Windows.Forms.Timer tmr = new System.Windows.Forms.Timer(); tmr.Interval = 1...

Timers in a .NET application

I would like to know what kind of timers can be used in a C# application and what are their implications in term of cuncurrency in a multi-threaded environment. Could you explain me or link me to an esaustive tutorial? Thank you. ...

VBA Macro On Timer style to run code every set number of seconds, i.e. 120 seconds

I have a need to run a piece of code every 120 seconds. I am looking for an easy way to do this in VBA. I know that it would be possible to get the timer value from the Auto_Open event to prevent having to use a magic number, but I can't quite get how to fire off a timer to get something to run every 120 seconds. I don't really want...

Does this code loop infinitely?

I have the following code, does this run an endless loop? I am trying to schedule something every minute and the console application should run continuously until I close it. class Program { static int curMin; static int lastMinute = DateTime.Now.AddMinutes(-1).Minutes; static void Main(string[] args) { // Not sure about this ...

Ensure jquery progress dialog is shown for at least some minimum time

I'm using a jquery ui dialog to let the user know that his request is in progress while the client is processing some data. However, as you all know, it takes a hell of a lot longer for ie to process than firefox. What's the best pattern for making sure that the progress dialog is displayed for at least some minimum amount of time, so ...