Example #1
0
        public void ReturnExtraPower(PowerRequestType type, uint powerReturned)
        {
            ThrowIfDisposed();
            var result = Interface.ReturnExtraPower(InterfaceRef, (uint)type, powerReturned);

            IOObject.ThrowIfError(result);
        }
Example #2
0
        /// <summary>
        ///  PowerClearRequest().
        /// </summary>
        public bool Clear(PowerRequestType requestType)
        {
            if (_powerRequest.IsClosed)
            {
                throw new ObjectDisposedException("_powerrequest");
            }

            return(mylib.WinApi.NativeMethods.PowerClearRequest(_powerRequest, ToNativeRequestType(requestType)));
        }
Example #3
0
        public uint ExtraPowerAllocated(PowerRequestType type)
        {
            ThrowIfDisposed();
            uint powerAllocated;
            var  result = Interface.GetExtraPowerAllocated(InterfaceRef, (uint)type, out powerAllocated);

            IOObject.ThrowIfError(result);
            return(powerAllocated);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
Example #7
0
 private static extern bool PowerClearRequest(
     SafePowerRequestHandle hPowerRequest, PowerRequestType RequestType);
Example #8
0
 internal static extern bool PowerClearRequest(IntPtr PowerRequestHandle, PowerRequestType RequestType);
Example #9
0
 static extern bool PowerClearRequest(IntPtr powerRequestHandle, PowerRequestType requestType);
Example #10
0
 public static extern bool PowerSetRequest(IntPtr PowerRequestHandle, PowerRequestType RequestType);
Example #11
0
 private static extern bool PowerClearRequest(IntPtr hPowerRequest, PowerRequestType RequestType);
Example #12
0
		public uint ExtraPowerAllocated (PowerRequestType type) {
			ThrowIfDisposed ();
			uint powerAllocated;
			var result = Interface.GetExtraPowerAllocated (InterfaceRef, (uint)type, out powerAllocated);
			IOObject.ThrowIfError (result);
			return powerAllocated;
		}
Example #13
0
		public void ReturnExtraPower (PowerRequestType type, uint powerReturned) {
			ThrowIfDisposed ();
			var result = Interface.ReturnExtraPower (InterfaceRef, (uint)type, powerReturned);
			IOObject.ThrowIfError (result);
		}
Example #14
0
		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;
		}
Example #15
0
 /// <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);