Re: slow NSWorkspaceDidWakeNotification
Re: slow NSWorkspaceDidWakeNotification
- Subject: Re: slow NSWorkspaceDidWakeNotification
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Wed, 16 Mar 2005 21:19:38 +0700
On 16.03.2005, at 08:07, Shaun Wexler wrote:
On Mar 15, 2005, at 12:05 PM, Sean McBride wrote:
On 2005-03-10 17:30, Gerriet M. Denkmann said:
So I implemented NSWorkspaceDidWakeNotification to update the time
immediately after waking up.
But: it takes 5 to 7 seconds for this notification to arrive (10.3.8,
iBook G4).
Is this normal? Do I make something wrong? Can I do something better?
Since no one else replied, I'll say 'yes, it is normal'. At least, I
see
the same thing. Maybe file a bug with Apple asking them to optimise
it.
#include "StdDisclaimer/WrittenInMail.app"
void SystemSleepCallBack(void *refcon, io_service_t service, natural_t
messageType, void *messageArgument)
{
if (messageType == kIOMessageSystemHasPoweredOn) {
;
}
}
io_connect_t rootPowerService;
io_object_t notifier;
IONotificationPortRef notificationPort;
rootPowerService = IORegisterForSystemPower(NULL, ¬ificationPort,
SystemSleepCallBack, ¬ifier);
CFRunLoopAddSource(CFRunLoopGetCurrent(),
IONotificationPortGetRunLoopSource(notificationPort),
kCFRunLoopCommonModes);
... or something to that effect. HTH~
Thanks very much for this code-fragment.
I copied it, added the IOKit Framework in Xcode, added
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <IOKit/IOMessage.h>
and it works.
When I put the computer to sleep (via the Apple-menu) I get after 1
seccond the message "kIOMessageSystemWillSleep", but then it takes 30
seconds until the computer really starts sleeping. This is not very
nice.
When I re-awake it (using the command-key) I get the message
kIOMessageSystemWillPowerOn immediately (the time in NSLog() is not the
real time - maybe it is the time the system did start sleeping) , 2
seconds later the screen lights up and after 7 seconds more I get
NSWorkspaceDidWakeNotification followed by kIOMessageSystemHasPoweredOn
one millisecond later.
So:
1. NSWorkspaceDidWakeNotification is not slow, but comes at the same
time as kIOMessageSystemHasPoweredOn.
2. Why is there the 30 seconds delay between kIOMessageSystemWillSleep
and the actual sleep?
What can I do to avoid this?
3. At kIOMessageSystemWillPowerOn the system time seems not yet to be
current, but contains some value from probably before going to sleep.
One second later the system clock seems to be ok.
Kind regards
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden