cfrunloop

Diagnosing run loop issue (partially frozen UI) in Cocoa application

纵饮孤独 提交于 2020-01-05 00:44:32
问题 Our application has a fairly standard layout - a main window with a toolbar, source list on the left hand side, and a tab control. The contents of the tabs is drawn by a third party component that is open source and very complex. It makes extensive use of threads, etc. Some users can reliably reproduce a situation where the whole application 'freezes' - which is to say, the main window stops redrawing. The cursor does not beachball, and the user can still click around, but the window simply

Diagnosing run loop issue (partially frozen UI) in Cocoa application

馋奶兔 提交于 2020-01-05 00:41:22
问题 Our application has a fairly standard layout - a main window with a toolbar, source list on the left hand side, and a tab control. The contents of the tabs is drawn by a third party component that is open source and very complex. It makes extensive use of threads, etc. Some users can reliably reproduce a situation where the whole application 'freezes' - which is to say, the main window stops redrawing. The cursor does not beachball, and the user can still click around, but the window simply

Diagnosing run loop issue (partially frozen UI) in Cocoa application

亡梦爱人 提交于 2020-01-05 00:40:08
问题 Our application has a fairly standard layout - a main window with a toolbar, source list on the left hand side, and a tab control. The contents of the tabs is drawn by a third party component that is open source and very complex. It makes extensive use of threads, etc. Some users can reliably reproduce a situation where the whole application 'freezes' - which is to say, the main window stops redrawing. The cursor does not beachball, and the user can still click around, but the window simply

CFRunLoopRun() vs [NSRunLoop run]

别说谁变了你拦得住时间么 提交于 2019-12-18 03:12:26
问题 I have an NSRunLoop object, to which I attach timers and streams. It works great. Stopping it is another story alltogether. I run the loop using [runLoop run] . If I try to stop the loop using CRunLoopStop([[NSRunLoop currentRunLoop] getCFRunLoop]) , the loop won't stop. If I start the loop using CRunLoopRun() instead, it works. I have also made sure that the call is made on the correct thread (the one running my custom run loop). I have debugged this with pthread_self() . I found a mailing

Callback method to Apple run loop

心已入冬 提交于 2019-12-13 20:57:58
问题 How to add a callback method to Apple event listener like: CFRunLoopSourceRef IOPSNotificationCreateRunLoopSource(IOPowerSourceCallbackType callback, void *context); How do i add a method or block to the following method so that when the power source changes I can log something like below, (I can see that it is C++ but NSLog still works in Obj-C++) something like: - (void)applicationDidFinishLaunching:(NSNotification *)notification { CFRunLoopSourceRef IOPSNotificationCreateRunLoopSource

Is it safe to call CFRunLoopStop from another thread?

旧巷老猫 提交于 2019-12-08 21:41:19
问题 The Mac build of my (mainly POSIX) application spawns a child thread that calls CFRunLoopRun() to do an event loop (to get network configuration change events from MacOS). When it's time to pack things up and go away, the main thread calls CFRunLoopStop() on the child thread's run-loop, at which point CFRunLoopRun() returns in the child thread, the child thread exits, and the main thread (which was blocking waiting for the child thread to exit) can continue. This appears to work, but my

Stop an NSRunLoop

微笑、不失礼 提交于 2019-12-04 00:57:33
问题 I have a connection in a thread, so I add it to the run loop to get all data: [[NSRunLoop currentRunLoop] run]; [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; But I can't find any way to stop it - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ if([NSRunLoop currentRunLoop]){ [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self]; } [connection cancel]; } How can I stop this loop? 回答1: You can stop the runloop by Core

Create a CFRunLoopSourceRef using IOPSNotificationCreateRunLoopSource in Swift

烈酒焚心 提交于 2019-12-01 23:40:03
问题 I am trying to subscribe to changes in power state on macOS. I discovered there is a way using IOKit, though it is a bit convoluted. I need to import it using #import <IOKit/ps/IOPowerSources.h> in an ObjC Bridging header. Then I get access to the function IOPSNotificationCreateRunLoopSource, which has the signature: IOPSNotificationCreateRunLoopSource(_ callback: IOPowerSourceCallbackType!, _ context: UnsafeMutablePointer<Void>!) -> Unmanaged<CFRunLoopSource>! I got some help from the answer

Create a CFRunLoopSourceRef using IOPSNotificationCreateRunLoopSource in Swift

泄露秘密 提交于 2019-12-01 20:57:34
I am trying to subscribe to changes in power state on macOS. I discovered there is a way using IOKit, though it is a bit convoluted. I need to import it using #import <IOKit/ps/IOPowerSources.h> in an ObjC Bridging header. Then I get access to the function IOPSNotificationCreateRunLoopSource, which has the signature: IOPSNotificationCreateRunLoopSource(_ callback: IOPowerSourceCallbackType!, _ context: UnsafeMutablePointer<Void>!) -> Unmanaged<CFRunLoopSource>! I got some help from the answer in Callback method to Apple run loop , but still doesn't manage to create a function of type

Stop an NSRunLoop

时光怂恿深爱的人放手 提交于 2019-12-01 04:02:42
I have a connection in a thread, so I add it to the run loop to get all data: [[NSRunLoop currentRunLoop] run]; [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; But I can't find any way to stop it - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ if([NSRunLoop currentRunLoop]){ [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self]; } [connection cancel]; } How can I stop this loop? You can stop the runloop by Core Fundation API : CFRunLoopStop(CFRunLoopGetCurrent()); 来源: https://stackoverflow.com/questions/16211915/stop-an