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

How to block until certain notification is posted in Cocoa?

What's the best way to sleep/wait until certain notification is posted? I've got class with asynchronous API that gets data from NSNotification (notification comes from Cocoa, I can't avoid it) and I need to unit test it. So far I've figured out…
Kornel
  • 97,764
  • 37
  • 219
  • 309
1
vote
0 answers

Main thread not getting stopped in cocoa

I am developing a desktop-based application in xcode4 that uploads files to ftp, flickr etc. I use multi threading while uploading. I need to cancel the entire uploads going on. Multithreading is done using "performselectorOnMainthread". So I need…
Sugan S
  • 1,782
  • 7
  • 25
  • 47
1
vote
0 answers

Stop NSThread execution when application will be sent in background mode

I have the following problem in my iphone application: I have a NSThread who works with a TCP socket. When this thread is performing a very long function, I send in the background mode the application. When I return from this background thread…
Safari
  • 11,437
  • 24
  • 91
  • 191
1
vote
2 answers

Runloop not processing events from dispatch_async

I'm having some issues using dispatch_async. On my applications main/UI thread, I call dispatch_async on the global queue, and tell it to go do some function call which has a completion handler. I'm expecting the completion handler to get called…
JPC
  • 8,096
  • 22
  • 77
  • 110
1
vote
0 answers

iPhone App rejected because of “non-public API” “ignore”

Apple has rejected my app, because it's using a non-public api, i.e. ignore. I am using XMPPFramework in my app, and in XMPPParser, the following line of codes are used NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // We can't run the…
Junaid Rehmat
  • 305
  • 2
  • 15
1
vote
3 answers

How can I call Method while app is in background in iOS?

I have one class name as myClassCalculate have the following method - (void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { NSLog(@"Accelerometer is called"); } I am making object in -…
Chatar Veer Suthar
  • 15,541
  • 26
  • 90
  • 154
1
vote
1 answer

calling an async function from within a timer

I have an async function that has to be called every given time from within a timer. In order to avoid an Xcode error, func firetimer() { let newtimer = Timer(timeInterval: 1.0, repeats: true) { newtimer in …
NightCoder
  • 1,049
  • 14
  • 22
1
vote
1 answer

Swift RunLoop: get notified on currentMode change

I'm interested in getting notified when the currentMode property of the RunLoop class changes, more specifically, I'm interested in getting an event when the mode is entering .tracking state. I've tried two different approaches: This one simply…
Richard Topchii
  • 7,075
  • 8
  • 48
  • 115
1
vote
0 answers

Swift - Timer.publish(:) misfires

I have a timer scheduled as following: private var timerCancellable: Cancellable? timerCancellable = Timer .publish(every: 1.0, on: .current, in: .common) .autoconnect() .scan(-1) { counter, _ in counter + 1 } .sink…
Asteroid
  • 1,049
  • 2
  • 8
  • 16
1
vote
1 answer

In iOS, How many times does RunLoop cycle in one second

In iOS, How many times does RunLoop cycle in one second? Is it the same as the screen refresh rate, 60 times a second?
emmm
  • 11
  • 1
1
vote
0 answers

SwiftUI | why does the wheelPicker not work as expected if a Timer is scheduled?

I have problem with making a selection with a wheelPicker if timer is running simultaneously. A) default as runloop mode of timer: the wheelPicker works fine and updates $selection But the counter in my ContenView won't keep counting while the…
nevrx
  • 37
  • 6
1
vote
4 answers

Ensuring the execution logic of two timers do not run at the same time

I have two timers that run at different time intervals, one of which is added to a runloop. let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in // do some stuff } let timer2 = Timer.scheduledTimer(withTimeInterval:…
user784637
  • 15,392
  • 32
  • 93
  • 156
1
vote
1 answer

How can I "visualize"(observe) a thread exiting in iOS?

When learning thread and run loop, I notice that some articles say: "Generally, a thread just exits once it has done its work." So there is necessity sometimes to create a so-called "immortal thread"(?? I don't know the exact term in English) using…
刘maxwell
  • 187
  • 10
1
vote
1 answer

Running callback on the same thread as the caller in iOS

I call a method on the native iOS side from Kotlin/Native framework. The method does its work asynchronously and responds back with some data in a different thread than it was called with. I want a way to call the response function also in the same…
kerry
  • 2,362
  • 20
  • 33
1
vote
1 answer

Difference between CFRunloopRun() and a simple infinite loop?

I schedule a HIDManager on the current runloop, which is the runloop for the main function. When I add the following line CFRunLoopRun(); All HID events will be captured and the output will be shown on the screen, which is compatible with the…
Patroclus
  • 1,163
  • 13
  • 31
1 2 3
8 9