Questions tagged [runloop]

A run loop is the concept of running a local loop waiting for a specific event or timeout.

A run loop is the concept of running a local loop waiting for a specific event or timeout.

Such a loop keeps the current thread busy and does not return until the loop has finished, which can either be by a timeout value, an explicit stop signal or if there are no events to process anymore (depends on the specific implementation). Message pumps/loops in applications to process incomming events are typical run loops. But there are other types of local loops (e.g. to make an originally asynchronous process synchronous).

126 questions
1
vote
0 answers

How to block a background thread until the main run loop sleeps?

I wish to block a background thread until my main thread's run loop is sleeping (aka the main thread is waiting for input). I think I can do this by doing: [self performSelectorOnMainThread:@selector(waitSelector) withObject:nil…
thewormsterror
  • 1,608
  • 14
  • 27
1
vote
1 answer

Always check Network Reachability in Cocoa

I'd like to know if what would be the best way to ALWAYS check if the app is connected to the network? Say, have it scheduled to check every 10seconds. Any help would be much appreciated.
Kimpoy
  • 1,974
  • 3
  • 21
  • 38
1
vote
1 answer

Monitor keyboard events by adding observer in RunLoop

My Run Loop Observer is written as follows: void observerCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void* info) { println("%u", activity); } //----------------------------- void InstallObserver() { …
mh taqia
  • 3,506
  • 1
  • 24
  • 35
1
vote
3 answers

Do Cocoa applications have a main loop?

On Linux under X11 and using GTK+ you have something called "Main Loop". Once you start the main loop you have a timer that runs in the main thread of the application. You can set that timer to a callback function and you have a very nice…
wonderer
  • 3,487
  • 11
  • 49
  • 59
1
vote
1 answer

CFRunLoop non-blocking wait for a buffer to be filled

I am porting an app reading data from a BT device to Mac. On the mac-specific code, I have a class with the delegate methods for the BT callbacks, like -(void) rfcommChannelData:(...) On that callback, I fill a buffer with the received data. I have…
antonae
  • 11
  • 3
0
votes
1 answer

Find out what's blocking the main thread/run loop in iOS?

is there a way to find out what is blocking the main thread's run loop in an iOS App, e.g. find all functions that the run loop calls that take longer than 0.1 secs to complete? Regards, Jochen
Jochen
  • 7,270
  • 5
  • 24
  • 32
0
votes
1 answer

is the frame after executing setNeedsLayout and layoutIfNeeded always get accurate view's frame?

My understanding is, after execute setNeedsLayout will mark the view as "dirty" so that in the next rendering cycle, the view will be be re-layout. layoutIfNeeded will force to trigger re-layout immediately if the view is marked as "dirty". However,…
Frank
  • 624
  • 9
  • 27
0
votes
1 answer

Can I use RunLoop for realtime object observing in Swift?

I have a Process object (is kind of Model). Inside a process, I have an array of tuples var listeners: [(WeakContainer, (S) -> ())] WeakContainer handles a weak ref inside. I need to remove an element from the listeners array when…
Ihor M.
  • 184
  • 10
0
votes
1 answer

Bug with Timer and/or RunLoop?

I had tested this extensively in the past before starting the project I'm working on. I copied and pasted the code into my new project, so it should work. All I want it to do is reload the tableView every minute, so that the clocks displayed on the…
jmsapps
  • 388
  • 2
  • 17
0
votes
3 answers

Move an object inside a loop that runs 60fps

I'm trying to setup a run loop, that will execute 60 times per second -- in my example I'd like to simply move add a px to the left position of a div every time the loop runs, but I think I'm doing something incorrectly. Would appreciate any help on…
Fuego DeBassi
  • 2,967
  • 6
  • 29
  • 37
0
votes
2 answers

What is the block that CFRunLoopPerformBlock() handles?

I'm currently learning the runloop mechanism in iOS. After reading Run, RunLoop, Run! and the CFRunloop source code, I'm still confused about how it really works. One of my confusions is about the CFRunLoopPerformBlock() function. Many articles…
P. Tsin
  • 435
  • 4
  • 14
0
votes
3 answers

RuntimeError: run loop already started in pyttsx

I am creating a DIY virtual assistant for fun and exercise in python. I run into a problem when trying to use engine.say in a thread and then use it again in my main program. I already tried to use engine.endLoop() and other possible solutions from…
Jim Noulis
  • 13
  • 3
  • 6
0
votes
2 answers

jQuery runloop - how to create a loop?

I am using jQuery runloop for a rather complex animation. Despite the name runLOOP I'm not able run the animation in a loop. Here is what I tried (simplified): var loop = jQuery.runloop(); loop.addKey('25%', function(){ console.log('25%'); …
dmnkhhn
  • 1,013
  • 1
  • 10
  • 18
0
votes
3 answers

UIViewController dismiss issue

I want to wait until dismiss animation completes but I don't want to use many blocks in my code, so I wrote this function in UIViewController extension (almost like this worked several years ago for me): func dismissAnimated() { var comleted:…
Paul T.
  • 4,938
  • 7
  • 45
  • 93
0
votes
1 answer

Fixing an iPhone crash with a run-loop stack trace

I'm using hoptoad to track errors in my iPhone app. One crash that's happened a number of times (14, to be exact), has this stack trace: https://gist.github.com/2ce8a88c07fc134a3d9c I'm not even sure how to start investigating this. Any clues? The…
smtlaissezfaire
  • 437
  • 2
  • 7
  • 18
1 2 3
8 9