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
2
votes
0 answers

Get notified each time RunLoop enters .tracking mode

How can I track and get notified each time the RunLoop's currentMode property changes to .tracking?
Richard Topchii
  • 7,075
  • 8
  • 48
  • 115
2
votes
1 answer

Is DispatchQueue using RunLoop?

Every Thread has its own RunLoop, how DispatchQueue interact with them? Is DispatchQueue using RunLoop to dispatch task to Thread or do it by another way?
2
votes
3 answers

Measure network latency in React Native

What would be the best way to measure network latency in React Native? E.g. const startTime = Date.now(); let response = await fetch(url) const endTime = Date.now(); const totalTimeInMs = endTime - startTime; If I place start and stop timer…
Yahoo
  • 4,093
  • 17
  • 59
  • 85
2
votes
1 answer

Why RunLoop doesn't block the whole thread from executing?

If each UIApplication initializes a RunLoop like this on the main thread void CFRunLoopRun(void) { /* DOES CALLOUT */ int32_t result; do { result = CFRunLoopRunSpecific(CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 1.0e10, false); …
Patroclus
  • 1,163
  • 13
  • 31
2
votes
2 answers

What's the C# equivalent of PostMessage for executing code on the current thread, just in the future?

I have a situation where I'm inside an event handler, and I need to change certain state information. However, it's not safe to change while I'm still in the handler, hence I need to execute it after I've exited. It does have to execute on the same…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
2
votes
0 answers

When calling popToRootViewController and setting tabBarController selectedIndex the popped VC did not call viewDidDisappear in the same runloop

I have a root tabbar vc and navigation vc with one home vc in the tabbar index 0, and one another vc in the tabbar index 1; Now I'm pushing to one subvc and this subvc is shown above on the homevc Then I triggered using button to pop this subvc out…
bolizhou
  • 1,208
  • 1
  • 13
  • 31
2
votes
1 answer

How to register a SIGINT handler that will run as soon as Ctrl+C is pressed?

I am writing a Python script that uses the PyObjC bindings for AppKit. The script registers an observer with the shared NSWorkspace's notificationCenter and then calls AppKit.CFRunLoopRun() in order for the notifications to be processed: from…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
2
votes
1 answer

(iphone) how to setup runloop properly here? many questions

I've just started reading apple's thread programming guide. I'm starting a thread and have a reference to it self.myThread = [[NSThread alloc] initWithTarget: self selector: @selector(myThreadMain) …
eugene
  • 39,839
  • 68
  • 255
  • 489
2
votes
0 answers

iOS 11 - iOSDeviceManager unable to install DeviceAgent on the device

Test execution stops after 2-3 hours on iOS 11 devices. The same setup works fine for iOS 10 devices. gems being used - run_loop - 2.6.1/2.6.0/2.5.4 calabash-cucumber - 0.21.1/0.20.5 cucumber - 3.0.0.pre.2 Xcode - 9 iOS - 11.0/11.0.1/11.0.2 Below…
Ram
  • 65
  • 4
  • 12
2
votes
1 answer

CFWriteStreamScheduleWithRunLoop sometimes works, sometimes not?

I'm doing async socket programming, and my code works, most of the time, but sometimes it doesn't. The gist is: I create a socket pair, create read and write streams, and then when I want to write something, I schedule it on a run loop of a separate…
Colin
  • 3,670
  • 1
  • 25
  • 36
2
votes
3 answers

Android: Forcing the main run loop to run before current thread of execution is complete

On iOS, if I want my current thread of execution to wait (ie. block) and the main loop to run so that the thread of execution next in the main queue can execute, I invoke: [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate…
gavdotnet
  • 2,214
  • 1
  • 20
  • 30
2
votes
0 answers

Debugging Coalesced Core Animations

I have a simple implicit UIView animation I'm trying to execute, like this: [UIView animateWithDuration:2 delay:0 options:0 animations:^{ [_testView setFrame:endFrame]; } completion:nil]; However, this animation happens instantly, disregarding…
Senior
  • 2,259
  • 1
  • 20
  • 31
2
votes
3 answers

What exactly is considered to be called the "Run Loop" here?

Before keeping on reading in the docs, my brain got stuck at this point: - (void)threadMainRoutine { BOOL moreWorkToDo = YES; BOOL exitNow = NO; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; // is this THE run loop? // some…
HelloMoon
2
votes
1 answer

the relationship of autorelease and runloop and thread?

I have a question about the autorelease,now I have the code below: int main(int argc, char *argv[]){ @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); }} the doc says at the end of the…
frank
  • 2,327
  • 1
  • 18
  • 20
2
votes
0 answers

How to use Core Foundation Message Ports to communicate between run loop sources

I have the following code where I attempt to create a message port for communication between two run loops. 1 run loop is executing instead of a pthread and the other is the main run loop. This function appears to function normally under a number…
Alex Barker
  • 4,316
  • 4
  • 28
  • 47
1 2
3
8 9