In practice, I have found that using a run loop on anything other than the main thread is a painful experience.
Fortunately, timers and delayed execution are also possible in the world of Grand Central Dispatch. The APIs are a bit intimidating, but thanks to Mike Ash, I did not have to fight too hard to decipher how to use them: the source code for MABGTimer is a great starting point, and it offers a familiar Objective C interface for managing a timer in a dispatch queue.
You may or may not need to introduce a new thread into your program. However, personally I would first attempt to solve your problem simply by removing the Invalidate from the On Paint handler. There are so many topics on the "ultimate c# game loop", but "they" say the easiest way to have a high frame rate game is to call Invalidate at the end of On Paint (for instance, but you are right; I'm flooding the message cue with On Paint which is why my poor timer never gets the message.
Pretty simple at a glance, it allows you to use your custom annotation - whatever class inherited from UIVIew class.For example, let's say, we would like to have a custom "text" annotation with "Y" text and place it on every X=100 position.With a bit of work, and with the help of PARDispatch Queue, one can have the best of both worlds.With run loops, you can easily fire a timer, or cancel it if you change your mind: However, timers and delayed execution only work as expected if you have a run loop set up on the current thread.Here's how we can make our scratch program do the same thing: Our scratch program displays the current time.
It also puts the time into the title bar so we can see the painting action (or lack thereof) when the window is covered or minimized, by watching the taskbar.
We are going to build on our previous Tutorial 06 - Adding Real Time Updates to add annotations to a chart in a realtime context.
But, let's take a look at how can we add simple annotation like Line, Box or Text.
Here the interval is set (in seconds) and the repeats flag. Define updater method The update Label:sender will be called by i OS notification every time, when timer interval will pass. I use kill Timer: method that handles it: Be careful: invalidating timer that was already invalidated will cause application to crash!
Sometimes you want to perform an activity, such as updating a status window, only as long as the window is not covered by another window.
The easiest way to determine this is by not actually trying to determine it.