objective c - Wait for flag from background thread -
When I start my program, I set some background to fire some other thread. This thread never dies, but before allowing the main thread to continue, I have to wait to complete it.
When I wait for the second thread to update, how can I block and start the main thread, is this the situation?
First of all, do not block the main thread. never. Blocking the main thread on IOS will kill your app for a long time. On OS X, it will be the reason for showing the rainbow pistol of death
Eventually, blocking the main thread becomes your app unresponsive.
Instead, throw applications to a modal dialog or a modal sheet or another status indicator that indicates that something before it should be released before app progress, make sure that the "dropped" menu item Still, when the user becomes "Oh, nonsense! There is no time! Abort! Abort! Abort!"
Then, when your background is threaded, use any different mechanism to transmit the main thread (GCD, Display: ..., etc ...), after which " The initial "instrument is removed.
There is no need to vote, sleep, or when () {} absolutely
My background has not been threaded, it always remains less or more and I need that the main thread can talk about it before you reach a specific state Can reach
Absolutely; Therefore, when he reaches that state, you can use it:
[someObject performSelectorOnMainThread: @selector (sshConnectionEstablished :) withObject: zero];
Where
some objects might be your app representative.
Or you can use the information and do something like this:
sending_ascientific (sender_net_man_close ()), ^ {[NSNation Centers Default Center] Post Notification Nominated: @ "ISSCHANCHATION ASTSTABILISHED" ....];});
Note that you want it to be async or sync is up to you.
Comments
Post a Comment