timer

How to implement a timer in C on windows

Hello All, How do I create a timer in C and after the time expires ,I should be able to call a callback function . The platform is windows. Can someone guide me Regards, Mithun ...

What is mach_absolute_time based on on iPhone

I use this code to keep track of last reboot: + (float) secondsSinceLastReboot{ return ((float)(mach_absolute_time())) * ((float)timebase.numer) / ((float)timebase.denom) / 1000000000.0f; } I assumed mach_absolute_time() was based on last device boot time like it is on a mac. It doesn't seem to be based on that. I actually have ...

Timer & TimerTask versus Thread + sleep in Java

I found similar questions asked here but there weren't answers to my satisfaction. So rephrasing the question again- I have a task that needs to be done on a periodic basis (say 1 minute intervals). What is advantage of using Timertask & Timer to do this as opposed to creating a new thread that has a infinite loop with sleep? Code snip...

Why is this C# timer code not working?

I need to be able to disable a button for 1.5 seconds at a time for an application I'm writing. An image is displayed, a user clicks a button, and then another image is displayed. I need to make sure that the user doesn't click the button again too quickly. So, when the image is displayed, I call this function: //when a new image...

How do I Acquire Images at Timed Intervals using MATLAB?

I'm a MATLAB beginner and I would like to know how I can acquire and save 20 images at 5 second intervals from my camera. Thank you very much. ...

How to tell if a refresh came from a Timer (C#)

I have a ton of update panels and such on my webform (which are created dynamically at runtime) I am wanting to put a locking timer or something similar in my form also. My problem is this. When someone is typing into a text box, and the timer happens they lose part of their text and the control loses focus. The reason this happens is...

C Programming. Calculate Elapsed Time in Milliseconds (UNIX)

I want to calculate the time in milliseconds taken by the execution of some part of my program. I've been looking online, but there's not much info on this topic. Any of you know how to do this? ...

UNIX System time and User time. C-Programming

Hi I'm trying to get the system time and the user time that are consumed by a program. I'm having some trouble though as my times are always zero in milliseconds. I think I'm doing something wrong. Can you guide me in the right direction ? Both of my methods return 0 typedef struct{ struct timeval ru_utime; /* user time used */ ...

UNIX Programming. struct timeval how to print it (C-programming)

I am trying to print a value of type timeval. Actually I am able to print it, but I get the following warning: Multiple markers at this line format ‘%ld’ expects type ‘long int’, but argument 2 has type ‘struct timeval’ The program compiles and it prints the values, but I would like to know if I am doing something wrong. Thanks. ...

System.Timers.Timer Elapsed taking 10 times longer to execute than a Button_click

I have a fairly process intensive method that takes a given collection, copies the items(the Item class has its Copy() method properly defined), populates the item with data and returns the populated collection to the class's collection property //populate Collection containing 40 items MyClass.CollectionOfItems = GetPopulatedCollection...

How can jQuery be used to handle timer in click, dblclick separation

I am using the jQueryFileTree at http://abeautifulsite.net/notebook/58 and I want to distinguish between the dblclick and click events as a click is always triggered by a dblclick. Googling about led to be a technique in which click is handled by a timer which kicks in when a dblclick does not cancel it. Is there some way this can be u...

Cocoa counterpart to Windows' SetTimer

Is there any equivalent function on OS X to SetTimer in Windows? I'm using C++. So I'm writing a plugin for some software, and I need to have a funtion called periodically. On Windows I just pass the address of the function to SetTimer() and it will be called at a given interval. Is there an easy way to do this on OS X? It should be as ...

getrusage() get system time, user time. Unix programming help

I am writing a shell where I need to launch several child processes at once and record the system time and user time. So far I am able to do it. The only problem is that I am using wait4 to grab the system resources used by the child program and put it in my rusage structure called usage. How can I launch all the processes at the same ...

rusage() measured in seconds or millseconds?

Hi I'm trying to get the system time and user time of applications being forked by a shell. I'm just not sure what kind of time I'm getting, seconds? milliseconds? Does anybody know? printf("System time: %ld.%06ld sec\n",usage.ru_stime.tv_sec, usage.ru_stime.tv_usec); printf("User time: %ld.%06ld sec\n\n",usage.ru_utime.tv_sec, usage...

High-Performance Timer vs StopWatch

Does anyone know if the HiPerfTimer or the StopWatch class is better for benchmarking, and why? ...

C++ Cross-Platform High-Resolution Timer

I'm looking to implement a simple timer mechanism in C++. The code should work in Windows and Linux. The resolution should be as precise as possible (at least millisecond accuracy). This will be used to simply track the passage of time, not to implement any kind of event-driven design. What is the best tool to accomplish this? ...

Textbox and focus problems with Timer controls(asp.net)

Hello. I am needing to create something like a lock timer(a little thing that just updates a lock time in a database). I thought the Timer control would suite my needs, but whenever the Timer control causes a partial post back, recently typed text in a textbox can disappear(inbetween the post back begin and post back end) and it loses fo...

(ASP.NET AJAX) How do you disable the ticker after it fires an event?

So i'm implementing a feature where after a user has visited my site, and not signed in and not registered for over two minutes, an alert pops up and asks them to take a survey. I agree, annoying, but it's a business requirement. I thought about doing a Session Object, and then in the page_load of the header (since it's on every page) ...

Coder's block: How to fire timer at intervals, compensating for early/late firing

I'm having a silly-yet-serious case of coder's block. Please help me work through it so my brain stops hurting and refusing to answer my questions. I want to fire a timer at intervals up to a final time. For example, if t = 0, my goal is 100, and my interval is 20, I want to fire at 0, 20, 40, 60, 80, and 100. The timer is not precise,...

How to run a task daily from Java?

How can I run a task daily at a specified time (say 11:00 am) using java.util.Timer? I'm using JDK 1.4.2, I know it's old, but it's what the project requires. ...