Created
July 29, 2012 17:22
-
-
Save mikeabdullah/3200382 to your computer and use it in GitHub Desktop.
Power assertion example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Begin the power assertion | |
IOPMAssertionID assertionID; | |
IOReturn asserted = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, | |
kIOPMAssertionLevelOn, | |
CFSTR("Sandvox Publishing"), | |
&assertionID); | |
if (asserted != kIOReturnSuccess) // handle the error; log it or something | |
// Do your long-running work | |
// End the power assertion | |
if (asserted == kIOReturnSuccess) | |
{ | |
asserted = IOPMAssertionRelease(assertionID); | |
if (asserted != kIOReturnSuccess) // handle the error; log it or something | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment