public void ReturnExtraPower(PowerRequestType type, uint powerReturned) { ThrowIfDisposed(); var result = Interface.ReturnExtraPower(InterfaceRef, (uint)type, powerReturned); IOObject.ThrowIfError(result); }
/// <summary> /// PowerClearRequest(). /// </summary> public bool Clear(PowerRequestType requestType) { if (_powerRequest.IsClosed) { throw new ObjectDisposedException("_powerrequest"); } return(mylib.WinApi.NativeMethods.PowerClearRequest(_powerRequest, ToNativeRequestType(requestType))); }
public uint ExtraPowerAllocated(PowerRequestType type) { ThrowIfDisposed(); uint powerAllocated; var result = Interface.GetExtraPowerAllocated(InterfaceRef, (uint)type, out powerAllocated); IOObject.ThrowIfError(result); return(powerAllocated); }
public uint RequestExtraPower(PowerRequestType type, uint requestedPower) { ThrowIfDisposed(); uint powerAvailable; var result = Interface.RequestExtraPower(InterfaceRef, (uint)type, requestedPower, out powerAvailable); IOObject.ThrowIfError(result); return(powerAvailable); }
internal WindowsPowerAvailabilityTask(PowerRequestType requestType, string reason) { RequestType = requestType; // Set up the diagnostic string _context.Version = POWER_REQUEST_CONTEXT_VERSION; _context.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING; _context.SimpleReasonString = reason; _request = PowerCreateRequest(ref _context); // Set the request if (!PowerSetRequest(_request, requestType)) { Logger.LogError($"Failed to set availability request (last Win32 error: {Marshal.GetLastWin32Error()})."); throw new NotImplementedException("Failed to set the availability request. Bailing out."); } }
private static extern bool PowerClearRequest( SafePowerRequestHandle hPowerRequest, PowerRequestType RequestType);
internal static extern bool PowerClearRequest(IntPtr PowerRequestHandle, PowerRequestType RequestType);
static extern bool PowerClearRequest(IntPtr powerRequestHandle, PowerRequestType requestType);
public static extern bool PowerSetRequest(IntPtr PowerRequestHandle, PowerRequestType RequestType);
private static extern bool PowerClearRequest(IntPtr hPowerRequest, PowerRequestType RequestType);
public uint ExtraPowerAllocated (PowerRequestType type) { ThrowIfDisposed (); uint powerAllocated; var result = Interface.GetExtraPowerAllocated (InterfaceRef, (uint)type, out powerAllocated); IOObject.ThrowIfError (result); return powerAllocated; }
public void ReturnExtraPower (PowerRequestType type, uint powerReturned) { ThrowIfDisposed (); var result = Interface.ReturnExtraPower (InterfaceRef, (uint)type, powerReturned); IOObject.ThrowIfError (result); }
public uint RequestExtraPower (PowerRequestType type, uint requestedPower) { ThrowIfDisposed (); uint powerAvailable; var result = Interface.RequestExtraPower (InterfaceRef, (uint)type, requestedPower, out powerAvailable); IOObject.ThrowIfError (result); return powerAvailable; }
/// <summary> /// convert PowerRequestType to Win32 API POWER_REQUEST_TYPE. /// </summary> /// <param name="requestType"></param> /// <returns></returns> private static mylib.WinApi.NativeMethods.POWER_REQUEST_TYPE ToNativeRequestType(PowerRequestType requestType) { return((mylib.WinApi.NativeMethods.POWER_REQUEST_TYPE)(UInt32) requestType); }
static extern bool PowerSetRequest(IntPtr powerRequestHandle, PowerRequestType requestType);