Note that there are some explanatory texts on larger screens.

plurals
  1. POC# .NET: How to check if we're running on battery?
    primarykey
    data
    text
    <p>i want to be a good developer citizen, <a href="http://blogs.msdn.com/oldnewthing/archive/2005/08/22/454487.aspx" rel="nofollow noreferrer">pay my taxes</a>, and disable things if we're running over Remote Desktop, or running on battery.</p> <p>If we're running over remote desktop (or equivalently in a Terminal server session), we must disable animations and double-buffering. You can check this with:</p> <pre><code>/// &lt;summary&gt; /// Indicates if we're running in a remote desktop session. /// If we are, then you MUST disable animations and double buffering i.e. Pay your taxes! /// /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; public static Boolean IsRemoteSession { //This is just a friendly wrapper around the built-in way get { return System.Windows.Forms.SystemInformation.TerminalServerSession; } } </code></pre> <p>Now i need to find out if the user is running on battery power. If they are, i don't want to blow through their battery. i want to do things such as</p> <ul> <li>disable animations</li> <li>disable background spell-checking</li> <li>disable background printing</li> <li>turn off gradients </li> <li>use <code>graphics.SmoothingMode = SmoothingMode.HighSpeed;</code> </li> <li>use <code>graphics.InterpolationMode = InterpolationMode.Low;</code></li> <li>use <code>graphics.CompositingQuality = CompositingQuality.HighSpeed;</code></li> <li>minimize hard drive access - to avoid spin up</li> <li>minimize network access - to save WiFi power</li> </ul> <p>Is there a managed way to see if the machine is <strong>currently</strong> running on battery?</p> <p><strong>References</strong></p> <p><a href="http://blogs.msdn.com/oldnewthing/archive/2005/08/22/454487.aspx" rel="nofollow noreferrer">How do you convince developers to pay their "taxes"?</a></p> <p><a href="http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx" rel="nofollow noreferrer">Taxes: Remote Desktop Connection and painting</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/ms724385(VS.85).aspx" rel="nofollow noreferrer">GetSystemMetrics(SM_REMOTESESSION)</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload