till now, happened once.
i use third-party library, , call function below:
- (bool) isreachableviawifi { nsassert(reachabilityref, @"isreachableviawifi called null reachabilityref"); scnetworkreachabilityflags flags = 0; networkstatus status = notreachable; if (scnetworkreachabilitygetflags(reachabilityref, &flags)) { status = [self networkstatusforflags: flags]; return (reachableviawifi == status); } return no; } // isreachableviawifi
when find ui stopped, paused program execution, , every time stops @ scnetworkreachabilitygetflags
line:
i'm confused that. tips.
basing on code you've posted problem synchronously call scnetworkreachabilitygetflags in main thread. think there big chance function pings on internet. if remote host tries ping not reachable reason(you've lost internet connection) ordinary network timeouts can long (30 sec). block main thread (with ui) time.
so solution problem be: call function on queue/thread , pass result main thread. doing not blocking main thread while waiting remote host response.
in general should avoid run network interaction code on main thread.
Comments
Post a Comment