SimplePingHelper icon indicating copy to clipboard operation
SimplePingHelper copied to clipboard

What is the usage of after delay time here.

Open hvaghela116 opened this issue 8 years ago • 4 comments

Hi,

I would like to know in detail what is the use of the following function. Anybody could you please explain in detail because I am facing timeout issue while try to connecting with wifi network.

[self performSelector:@selector(endTime) withObject:nil afterDelay:2];

is it necessary to call above function and what will be the effect if we would not use this function. Please explain in detail.

Thanks in advance.

  • (void)go { if ([NSThread isMainThread]) { [self.simplePing start]; //[self performSelector:@selector(endTime) withObject:nil afterDelay:2]; // This timeout is what retains the ping helper } else { dispatch_sync(dispatch_get_main_queue(), ^{ NSLog(@"Moving ping to main thread"); [self.simplePing start]; // [self performSelector:@selector(endTime) withObject:nil afterDelay:2]; }); }

}

hvaghela116 avatar Mar 09 '17 12:03 hvaghela116

IIRC, it is used so that the runloop keeps a reference to 'self' for a couple seconds, otherwise self gets deallocated and you'd get no callbacks.

On Thu, Mar 9, 2017 at 11:45 PM, hvaghela116 [email protected] wrote:

Hi,

I would like to know in detail what is the use of the following function. Anybody could you please explain in detail because I am facing timeout issue while try to connecting with wifi network.

[self performSelector:@selector https://github.com/selector(endTime) withObject:nil afterDelay:2];

Thanks in advance.

  • (void)go { if ([NSThread isMainThread]) { [self.simplePing start]; //[self performSelector:@selector https://github.com/selector(endTime) withObject:nil afterDelay:2]; // This timeout is what retains the ping helper } else { dispatch_sync(dispatch_get_main_queue(), ^{ NSLog(@"Moving ping to main thread"); [self.simplePing start]; // [self performSelector:@selector https://github.com/selector(endTime) withObject:nil afterDelay:2]; }); }

}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chrishulbert/SimplePingHelper/issues/7, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAjMkt3ABJ2P9Hg7vx5QtYJPz5hdu1Tks5rj_RjgaJpZM4MYCR2 .

chrishulbert avatar Mar 09 '17 22:03 chrishulbert

Thanks chrishulbert for your response. I have been working in wifi project and trying to connect wifi. but If I will use that line then it is creating timeout issue and if I would not use then It would not create and would able to connect wifi network without any interruption.

hvaghela116 avatar Mar 10 '17 16:03 hvaghela116

Something to consider: you might be better off using reachability or a bonjour library. Best of luck!

On Sat, Mar 11, 2017 at 3:53 AM, hvaghela116 [email protected] wrote:

Thanks chrishulbert for your response. I have been working in wifi project and trying to connect wifi. but If I will use that line then it is creating timeout issue and if I would not use then It would not create and would able to connect wifi network without any interruption.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chrishulbert/SimplePingHelper/issues/7#issuecomment-285722235, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAjMoTf2FxX7RggPxCn3AY6yyFapBFvks5rkYAMgaJpZM4MYCR2 .

chrishulbert avatar Mar 11 '17 08:03 chrishulbert

Thanks Chris Hulbert. It can be an issue. I will check it.

hvaghela116 avatar Mar 16 '17 17:03 hvaghela116