简体   繁体   中英

Application got stuck with CPU usage up to 100%

My application stuck with CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION . In my application, I called an C function which is async. I show an waiting msg during the execution.
When this function is terminated, it calls a delegate to close that waiting msg and show in same time an AlertView.

I use gcd to show the alertview

dispatch_async(dispatch_queue_create("com.myapp.service.waitingmessage", nil), ^{
            dispatch_async(dispatch_get_main_queue(), ^{
            UIAlertView *anAlert = ...
            [anAlert show];
             });
        });

Here is the screenshot of the Debugger XCode when application got stuck. I see also that the CPU usage of my application is up to 100%, maybe that why the application is suspended by the system.

在此处输入图片说明

Use dispatch_sync() in place of dispatch_async(dispatch_get_main_queue(), ^{...

You can't update the UI from a background thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM