Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
- Subject: Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
- From: email@hidden
- Date: Wed, 30 Sep 2009 17:59:00 +0100
Before entering sleep I would like to send small amounts of data via
async instances of CFSocket to the local and some remote hosts.
So I register for the sleep notification:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
selector: @selector(appWillSleep:) name:
NSWorkspaceWillSleepNotification object: NULL];
And tell all my local and remote things to stop:
- (void) appWillSleep:(NSNotification*) note
{
[[thingHandler sharedInstance] stopAllRunningThings:self];
}
Now I presume that the 30 second sleep delay referred to in the docs
for NSWorkspaceWillSleepNotification means that my app can dawdle in -
appWillSleep for 30 seconds.
Is this correct?
If so then it seems likely that when this method returns the machine
may sleep before all the network data requests complete.
Is it possible to finagle the runloop within -appWillSleep to allow my
runloop attached CFSockets to persist for up to 30s before sleep
overpowers me?
Or have I got this all wrong?
Thanks
Jonathan Mitchell
Developer
http://www.mugginsoft.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden