timer

cancel dialog after 3 seconds - keeps crashing my app after multiple uses

I have an extended dialog class that I want to show for 3 seconds then disappear. This works great the first 2 times it's called, but then it crashes my app after that. Admittedly, I'm not the best with threads and I think that's where my problem might be. As you can see from the code below (commented out section), I tried using a can...

High-resolution timer for iPhone?

I'm looking for high-resolution timing code for iPhone, in order to do some performance timings. I'd like to write code like this: HighResolutionTimer* myTimer = [[HighResolutionTimer alloc]init]; [myTimer start]; [self doSomeLengthyOperation]; NSLog( @"doSomeLengthyOperation took %f seconds", [myTimer elapsedTime] ); ...

Android Threading Issue

I have the following code that I want to be able to loop every 30 seconds. MyLocation myLocation = new MyLocation(); public LocationResult locationResult = new LocationResult() { @Override public void gotLocation(final Location location) { GeoPoint myGeoPoint = new GeoPoint( (int) (loc...

Is my use of Timer and TimerTask creating a concurrency problem

Ive create a game and the portion of the program I am having a problem is modeled with a slightly modified MVC model. For the controller I use a TimerTask to run 60 times a second. Controller(){ timer = new Timer();// timer.schedule(tt,1000,1000/60); } TimerTask tt = new TimerTask() {//Controller member variable public void...

C++ Countdown timer for the iPhone

I am trying to write an ultra-portable game in C++. In one of the modes of my game, it will be timed - counting down. How would I go about writing that in C++, without using NSTimer? Thanks in advance. ...

Process Queue Timer

I want to scan a queue every 10 seconds using a Timer. If there are more then 0 items in this queue then Deque the first one, pass it as an argument to a Process and run that process. The timer should be disabled while this process executes. Once the process exits, it should re-enable the timer. The items in the queue can be added manua...

Timing rapid events

I'd like to measure the amount of time taken to complete a rapid event but the time taken is comparable to the accuracy of my timer. Can I measure the distribution of times taken to perform the operation several times and then reverse engineer the underlying distribution, i.e. solve p₁= p₂* p₂ using deconvolution? ...

C# - How can I block a method return for some interval of time?

I have a win forms application that contains a Web Browser control. I need to be able to add delay between operations on the web-browser due to the asynchronous nature of navigating. The Document_Complete event is worthless as it does not take into account that a page may contain multiple AJAX requests. The event ofter fires many times...

iphone : precisely timed alarms or alerts

What are the options(if any) for precisely timed alarms or alerts from within an iphone app? My app may need to alert the user in 30 seconds or 5 hours and 23 seconds. I assume for shorter times I could just use NSTimer, but what is the cutoff point(if there is one) for a timer to be fired within the app? For longer timed alarms or ale...

Are EJB3 Timers inherit to the beans they are created by?

Timers are created in EJB3 using the TimerService.createTimer(), and are then run via whatever callback method that's annotated by the @Timeout annotation, i.e: @Resource private TimerService timerService; public void createHampster() { Hampster hampster = new Hampster("Fluffy III"); timerService.createTimer(3000, 3000, hampste...

In VB.NET, wait for a Timer Or a KeyPress

I have a console application which is intended to just keep running until it is killed. Essentially: <setupCode> Do <doProcessing> Thread.Sleep(<interval>) Loop Essentially this will keep running until the user kills it, obviously. What I'd like to do is replace the Thread.Sleep call with a wait-condition waiting on eith...

Setting string content

I'm trying to make a timer in which you can insert how much time you want by clicking on the textview or some other button. My problem is I can not figure out how to get the code right so that it will set the string. The string is one that is set up before the class in the string xml. Here is the code that I am working with. This is the ...

Where is a good place to grab GPS data?

I in my android application I want to track GPS information and use this information in all activity. Is it a good way to use onLocationChanged, in the Application class? I also want to have a timer that will measure the elapsed time, and use in all applications not only in one Activity The information onLocationChanged and timer and ...

Problem creating a timer in Objective C for the Iphone

I've been having alot of problems creating a timer for a iphone application, currently I have a label displaying my timer, but it is just displaying the variable i (2700) in the label, and not decreasing by one every second. Its really driving my head in as this is really my 1st attempt coding in obj C, and for the life of me I cannot ge...

Java Timer Reusage

I'm currently trying to get a small brick-breaker game I made to effectively use some form of power-ups or bonuses. I have have it mostly implemented right now. However I have a problem. I use java.util.Timer to determine how long the power-up lasts. Most likely, that power-up is going to be chosen (by a random number generator) more tha...

NSTimer : applicationDidEnterBackground : countdown (how to keep state)

I have a simple countdown timer that updates a label every second. How do I keep state or the illusion of it when hitting the home button or when the app gets put in the background? ...

Best way to play sound on a timed interval?

I have an Android app which needs to play a sound resource on a timed interval, say every 120 seconds. I know how to access the sound resources and play them, however it's time timer part I'm not sure of. What's the best approach? ...

Java unlimited thread stops after some time

Hey fellows I hope you are doing well! So the problem is like this: I have a web server and some data storage kind of servers. What I need is synchronization between both the servers. Web servers are always up, and I try to keep the data servers up as long as possible. Both have mysql databases and I already have written scripts to syn...

Telling the timer object to invoke its "Elapsed" event asynchronously

There are times in my application, when I need to invoke my timer manually. I've tried the following: int originalInterval = t.Interval; t.Interval = 0; t.Interval = originalInterval; but it wasn't consistent. I've created a new timer, inheriting from System.Timers.Timer, and exposed a "Tick" method - but the problem was that the "E...

Thread-safe asynchronous code in C#

Hi all, I asked the question below couple of weeks ago. Now, when reviewing my question and all the answers, a very important detail jumped into my eyes: In my second code example, isn't DoTheCodeThatNeedsToRunAsynchronously() executed in the main (UI) thread? Doesn't the timer just wait a second and then post an event to the main threa...